[英]php email changing the “from” address
我正在尝试使用干净的“发件人”地址发送自动电子邮件。 当它使用@ my-website.com附带的名称发送电子邮件时,我该如何摆脱它?
例
$address = "user@example.com";
$subject = "Confirmation";
$msg = "Registered";
$headers = "From: MyWebsite \r\n";
mail($address, $subject, $msg, $headers);
我测试时收到的收件箱是MyWebsite@my-website.com,而不仅仅是MyWebsite
我认为
$headers = "From: MyWebsite <MyWebsite@my-website.com> \r\n";
会做
尝试这个:
$headers = "From: MyWebsite <MyWebsite@my-website.com> \r\n";
这将在大多数电子邮件客户端中显示名称“MyWebsite”,还包括您的电子邮件地址。 (有效的电子邮件应该有真实的发件人:电子邮件地址。)
尝试将from地址设置为字符串(包括引号):
"MyWebsite" <whatever@my-website.com>
它工作正常。 您需要使用完整域名mail()
它需要的mail()
函数来解析和法律下的CAN-SPAM
法案。
您不能将MyWebsite
指定为发件人,因为它不是有效的电子邮件地址。 您可以尝试以下代码:
$headers = "From: MyWebsite <whatever@my-website.com> \r\n";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.