I am having issues with $headers = "From: $from\r\n";
Here is the issue: If I leave the \r in the line the From address will appear properly (ie: user@some-domain.com) but the body will start with some strange server code:
Message-Id: <E18HSIT-0000zl-00@wolverine>
Sender: www-data <www-data@wolverine.some-domain.com>
Date: Thu, 28 Nov 2002 12:17:54 -0500
X-UIDL: 2_5!!D~U"!oE\"!VQT!!
and the rest will be displayed properly.
Now, if I remove the every instance of the \r from the $headers variable and only use \n then the From: address will be:
www-data[www-data@wolverine.some-domain.com] on behalf of user@some-domain.com
then the body will be displayed properly.
Does anyone have an idea what it happening here. The full test code it below, basically it was copied from the php.net site. For this post I substituted my real FQDN with some-domain.com in case anyone is wondering.
/ recipients /
$to = "User <user@some-domain.com>";
/ subject /
$subject = "mail test";
/ message /
$message = 'testing php mail function';
/ additional headers /
$headers = "From: User <user@some-domain.com>\r\n";
$headers .= "X-Sender: Mail-Admin <mail-admin@some-domain.com>\r\n";
$headers .= "X-Mailer: PHP\r\n"; //mailer
$headers .= "Return-Path: Mail-Admin <mail-admin@some-domain.com>\r\n";
/ To send HTML mail, you can set the Content-type header. /
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/plain; \tcharset=\"us-ascii\"\r\n";
/ and now mail it /
mail("user@some-domain.com", "the subject", $message, $headers);