title: How to change envelope from address using PHP mail?
body: <p>I am using PHP with Apache on Linux, with Sendmail. I use the PHP <a href="http://php.net/manual/en/function.mail.php" rel="noreferrer"><code>mail</code></a> function. The email is sent, but the envelope has the <code>Apache_user@localhostname</code> in <code>MAIL FROM</code> (example nobody@conniptin.internal) and some remote mail servers reject this because the domain doesn't exist (obviously). Using <code>mail</code>, can I force it to change the envelope <code>MAIL FROM</code>?</p>
  
  <p>EDIT: If I add a header in the fourth field of the <code>mail</code>() function, that changes the <code>From</code> field in the headers of the body of the message, and DOES NOT change the envelope <code>MAIL FROM</code>.</p>
  
  <p>I can force it by spawning sendmail with <code>sendmail -t -odb -oi -frealname@realhost</code> and piping the email contents to it. Is this a better approach?</p>
  
  <p>Is there a better, simpler, more PHP appropriate way of doing this?</p>
  
  <p>EDIT: The bottom line is I should have RTM. Thanks for the answers folks, the fifth parameter works and all is well.</p>