加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php邮件与outlook无法完美配合

发布时间:2020-12-13 16:15:51 所属栏目:PHP教程 来源:网络整理
导读:我使用 PHP发送邮件时遇到问题. Outlook正确接收邮件,但它不显示电子邮件中的“发件人”地址. $subject = $_POST['message_subject'];$message = $_POST['speaker_description'];$email = $_POST['email'];$option = $_POST['sel_reg_options'];$email = sub
我使用 PHP发送邮件时遇到问题. Outlook正确接收邮件,但它不显示电子邮件中的“发件人”地址.

$subject = $_POST['message_subject'];
$message = $_POST['speaker_description'];
$email   = $_POST['email'];
$option  = $_POST['sel_reg_options'];
$email   = substr_replace($email,"",-1);

$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From:My Name<myifno@mysite.com>rn";
$headers .= "Reply-To: Registration of Interest<info@mysite.com>rn";          
$headers .= "MIME-Version: 1.0"."rn";
$mail_sent = @mail($email,$subject,$message,$headers);

解决方法

您应该将名称括在双引号中(这也适用于Reply-To地址名称):

$headers .= "From: "My Name" <myifno@mysite.com>rn";

此外,如果在Unix上运行PHP,请将FROM信封添加到$additional_parameters参数:

$mail_sent = @mail($email,$headers,'-f myifno@mysite.com');

相反,如果在Windows上运行,请在php.ini中设置sendmail_from INI指令,或者使用:

ini_set('sendmail_from','myifno@mysite.com');

资料来源:RFC2822,php.net user comment,IBM sendmail command reference

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读