title: Sending mail on PHP using LAMP
body: <p>I have been trying for awhile now to send mail using PHP, and I can't seem to get it to work. </p>
  
  <p>I looked at the tutorials, and they make it seem simple enough. Yet, it seems to actually require more work than what is mentioned. Through research (to make this short), it seems that instead of the "From: " header actually having the address I give to it, it seems that... sendmail replaces it or something with daemon@ubuntu? Ok, even if I don't include a header I still get spam from my gmail account from the daemon@ubuntu thing (I am running ubuntu on a vm, and sending mail to my gmail account). I guess this could explain why I incessantly get errors when I try to send mail saying how there is an error in the "MAIL FROM command".</p>
  
  <p>So before I get myself involved with messing around with sendmail, is this the (likely)culprit of the daemon@ubuntu nonsense? The tutorials make mention of having things like sendmail, but they really don't go into any details of what to do with them. I did make sure that sendmail is being used in my php configuration file.</p>
  
  <p>I have heard of alternative mail servers like PHPmail or something like that. I really don't want to get involved in installing and configuring more software unless I really have to. So unless you guys really think sendmail isn't worth it, I would prefer advice on sendmail if it is the problem.</p>
  
  <p>Thank you for your time.</p>
  
  <p>edit: I am using the PHP mail() function on an Ubuntu vm by VMware Player.</p>
  
  <p>So someone wanted to see my code. I somewhat wanted to avoid this simply because I tried many different possibilities. I will just include what I have in my file right now:</p>
  
  <pre><code>&lt;?php
                      $myEmail    = "####@gmail.com";
                      $fromAddr   = $_POST['sender-email'];
  
                      $headers    = "MIME-Version: 1.0\r\n";
                      $headers   .= "Content-type: text/html; charset=iso-8859-1\r\n";
                      $headers   .= "From: $fromAddr\r\n";
                      $headers   .= "'X-Mailer: PHP/'" . phpversion() . "\r\n";
                      $message    = $_POST['message'];
  
                      $status     = mail($myEmail, $_POST['subj'], $message);
  
                      if($status) {
                          echo "Your message has been sent, " .$fromAddr. "!";
                      }
                      else {
                          echo "An error occurred while trying to send the mail.";
                      }
                  ?&gt;
  </code></pre>
  
  <p>The MIME type thing, and Content-type thing I added later on. I have tried this without them. I have also tried sending mail without using any headers at all, and still apparently get the daemon@ubuntu thing. Also, I edited out my e-mail address to post the code on here. Ok I guess I should add this too: I am getting the data from an HTML form from another page. On submit, I come to this php page where it grabs that data and then sends the email (this isn't for anything professional, I am just doing this to learn more about web stuff).</p>