title: php's mail() is overriding the 'from' email address
body: <p>I'm using PHP's mail() -- my emails from our site get sent and received successfully.</p>
  
  <p>User "theArtist" puts a painting up for sale on our site.  User "RichGuy" sees it, and our site has a form where RichGuy types his email address and a message to "theArtist."</p>
  
  <p>When "RichGuy" fills out this form and clicks 'send', our PHP code retrieves the artist's email address from the database and makes that the "To" email address used in the call to mail().  And since RichGuy just entered his reply email on that form, "RichGuy@gmail.com" is used for the "From: " header in the call to mail().  </p>
  
  <p>I set up two dummy email accounts to test our mail() code, one to send mail (RichGuy@gmail.com and one to receive mail (theArtist@hotmail.com).</p>
  
  <p>My real name is the problem, because it shows up in the 'From' part in the recipient's received message.  My real name and my hotmail email are 
  <strong>FredSmith@hotmail.com</strong>.   NOTE THAT "theArtist" also is a hotmail.com account, not sure if that has a bearing here.  I've had my FredSmith@hotmail.com account for many years now.  The other two 'dummy' accounts are new, just for testing this mail() code.</p>
  
  <p>Here's the PHP code:</p>
  
  <pre><code> $sendTo = "theArtist@hotmail.com";
   $subject = "I want that painting now!";
   $theMsg =  "That's a fine abstract piece, I'll buy it.";
   $headers = "From: RichGuy@gmail.com";
  
   if(mail($sendTo, $subject, $theMsg, $headers))
   {
         // success
   }
  </code></pre>
  
  <p>The above email is successfully being received by theArtist@hotmail.com -- here's what "theArtist" receives:    </p>
  
  <hr>
  
  <h1>I want that painting now!</h1>
  
  <p><strong>Fred Smith</strong> (RichGuy@gmail.com)</p>
  
  <p>To: theArtist@hotmail.com</p>
  
  <p>From:   RichGuy@gmail.com</p>
  
  <p>Sent:   Tue 9/24/13 8:20 PM</p>
  
  <p>To:     theArtist@hotmail.com</p>
  
  <p>That's a fine abstract piece, I'll buy it.</p>
  
  <hr>
  
  <p>Why in the heck does my real name, Fred Smith, appear in theArtist@hotmail.com's email like this?  Is mail() behind the scenes, despite my using the 2 dummy email accounts, authenticating using my real name?  I see the same behavior on both my localhost web server and our staging server running live on the web.  </p>
  
  <p>So I tried to force the issue as follows:</p>
  
  <pre><code> $sendTo = "theArtist@hotmail.com";
   $subject = "I want a deal on that painting";
   $theMsg =  "How about a discount on your painting?";
   $headers = "From: RichGuy@gmail.com";
   if(mail($sendTo, $subject, $theMsg, $headers, '-fRichGuy@gmail.com'))
  </code></pre>
  
  <p>NO CHANGE.  My <em>real name</em>, Fred Smith, is somehow tacked on right before the sender's email address, RichGuy@gmail.com --</p>
  
  <hr>
  
  <h1>I want a deal on that painting</h1>
  
  <p><strong>Fred Smith</strong> (RichGuy@gmail.com)</p>
  
  <p>To: theArtist@hotmail.com</p>
  
  <p>From:   RichGuy@gmail.com</p>
  
  <p>Sent:   Tue 9/24/13 8:20 PM</p>
  
  <p>To:     theArtist@hotmail.com</p>
  
  <p>How about a discount on your painting?</p>
  
  <hr>
  
  <p>Could this be an authentication issue somehow?<br>
  Is it possible that mail() recognizes "ah-HAH, the real 'owner' of the site is Fred Smith, so we cannot authenticate on RichGuy@gmail.com nor on theArtist@hotmail.com, we have to authenticate prior to emailing on FredSmith."</p>
  
  <p>By the way, I checked the sendmail debug.log on my localhost web server and there is NO "Fred Smith" logged there with the email messages.  </p>