Mail From header
Could some one point out why isnt the From: header working? Instead I am receiving something like myhost@conf....
<?php
$send=$_POST['send'];
if ($send){
$to="example@hotmail.com";
$subject=$_POST['subject'];
$headers = 'From: webmaster@example.com';
$firstname=$_POST['firstname'];
$body=$_POST['message'];
$mailers_name=ucwords($firstname);
if (!mail($to,$subject,$body,$headers))
{
header("LOCATION: http://www.mysite.co.uk/success.php?none=not");
}else {
header("开发者_如何转开发LOCATION: http://www.mysite.co.uk/success.php?none=yes");
}
}
?>
I believe you need \r\n
in there at the end
$headers = 'From: webmaster@example.com' . "\r\n";
OR
$headers = "From: webmaster@example.com\r\n";
From the user notes at the PHP manual for mail, the following was posted by me at arronwoods dot com:
I've had all sorts of problems with scripts that don't set the "-f user@example.org" parameter when using mail() if postfix is the sendmail agent.
In postfix I had SMTP relay authentication based on the sender address, but it was always the PHP user as the sender until I adapted the code from:
<?php mail('test@example.org', 'Subject', 'Body', 'From: user@example.org'); ?>
to:
<?php mail('test@example.org', 'Subject', 'Body', 'From: user@example.org', '-f user@example.org'); ?>
精彩评论