PHP 发送邮件显示名称而不是电子邮件
PHP send mail show name instead of an email
//send email
$to = $_POST['email'];
$subject = "Welcome!";
$body = "Contains sensitive information that activates users so I've removed it.";
$additionalheaders = "From: <".SITEEMAIL.">\r\n";
$additionalheaders .= "Reply-To: ".SITEEMAIL."";
mail($to, $subject, $body, $additionalheaders);
基本上上面的代码成功发送了一封电子邮件,并且在收件箱中它显示为 noreply@mydomain,这很好,但我注意到其他网站显示的是真实姓名。像来自 Facebook 的消息说 Facebook 不是 noreply@facebook.com。是否有 header 我缺少完成此操作的方法?
编辑显示答案:
//send email
$to = $_POST['email'];
$subject = "Welcome!";
$body = "Contains sensitive information that activates users so I've removed it.";
$additionalheaders = "From: Name <".SITEEMAIL.">\r\n";
$additionalheaders .= "Reply-To: ".SITEEMAIL."";
mail($to, $subject, $body, $additionalheaders);
from: Jon Jones <Jon@Jones.com>
//send email
$to = $_POST['email'];
$subject = "Welcome!";
$body = "Contains sensitive information that activates users so I've removed it.";
$additionalheaders = "From: <".SITEEMAIL.">\r\n";
$additionalheaders .= "Reply-To: ".SITEEMAIL."";
mail($to, $subject, $body, $additionalheaders);
基本上上面的代码成功发送了一封电子邮件,并且在收件箱中它显示为 noreply@mydomain,这很好,但我注意到其他网站显示的是真实姓名。像来自 Facebook 的消息说 Facebook 不是 noreply@facebook.com。是否有 header 我缺少完成此操作的方法?
编辑显示答案:
//send email
$to = $_POST['email'];
$subject = "Welcome!";
$body = "Contains sensitive information that activates users so I've removed it.";
$additionalheaders = "From: Name <".SITEEMAIL.">\r\n";
$additionalheaders .= "Reply-To: ".SITEEMAIL."";
mail($to, $subject, $body, $additionalheaders);
from: Jon Jones <Jon@Jones.com>