Php mail out to mobile / sms / text; missing from, via headers
For some reason, when php mail() is sent to a text number (via email) i.e. 123456789@vtext.com; the from shows up as the centos apache server output email (apache@host-name.com). However, I've included the correct headers; so when the same mail() is pushed to (for example) gmail it comes and shows normal with all the correct headers / mime type / from.
Any idea?
Here's the code for the normal mail
$headers = "From: Alert@thedomain.com \r\n";
$开发者_Go百科headers .= "Date: ". date('r') . "\r\n";
$headers .= "Content-Type: text/html; charset=utf-8";
$headers .= "MIME-Version: 1.0 ";
$body = "body message";
mail($userinfo->username,"thedomain",$body,$headers);
And the code for the mobile: (We don't use date/content type/ mime for text msgs, or else the headers shows up in the txt msg)
$headers = "From: Alert@thedomain.com \r\n";
$body = "body message";
mail($userinfo->mobile,"thedomain",$body,$headers);
Try sending with the additional -f
flag to the mail function:
mail($userinfo->username,"thedomain",$body,$headers, "-ffromaddress@example.com");
See the manual for more information on additional parameters
精彩评论