Here are headers for emailing through PHP’s mail() function:
$headers = “MIME-Version: 1.0rn”;
$headers .= “Content-type: text/html; charset=iso-8859-1rn”;
$headers .= ‘From: My Website <email@mywebsite.com>’;
if ($_POST[‘cc_sender’]) $headers.= “rnCC:”.$_POST[‘Email’].””;
I use this for all websites that I build, and I distribute my code for free as well. Formal information about this can be found at http://www.php.net/function.mail as well.
So I was pretty surprised when a standard contact form of mine came to me while testing with this as the “from”: ABC@osd2.myhostcenter.com. Why? Everything was set up properly. I contacted my host, and they insisted that I wasn’t entering “RFC compliant” headers. Their suggestion was to enter the from headers as ONLY an email.
Well, turns out, that’s not what I had to do. I had entered the company’s name with a comma, as in ABC, LLC. I removed the comma, and now the email works fine.
Here’s what the standards say:
3.6.2. Originator fields
...The from field consists of the field name "From" and a
comma-separated list of one or more mailbox specifications...
I’m not sure what my comma was telling it to do, but now I know that commas are not allowed. I will be updating my PHP script to include this new information.