我使用php的邮件功能发送电子邮件。电子邮件客户端中的某些地址(如aol,hotmail.com和msn)未收到该地址。 Gmail工作正常!我发现它很奇怪,因为它可以通过Gmail而不是其他人:
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers = "From: $from";
$headers .= "\r\nMIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
然后我使用以下方式发送电子邮件:
$ok = @mail($to, $subject, $message, $headers);
出于诊断目的,$header
字符串包含:
From: xxx@example.com
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="==Multipart_Boundary_xd31b2fcd6941ba77b38f866330c24944x"
并且$message
字符串包含:
This is a multi-part message in MIME format.
--==Multipart_Boundary_x0dde39863d56158409aa962fc1dd9a3bx
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
The email message appears here
--==Multipart_Boundary_x0dde39863d56158409aa962fc1dd9a3bx
Content-Type: {"application/octet-stream"};
name="afile.pdf"
Content-Disposition: attachment;
filename="afile.pdf"
Content-Transfer-Encoding: base64
The attachment's contents here
--==Multipart_Boundary_x0dde39863d56158409aa962fc1dd9a3bx
答案 0 :(得分:0)
电子邮件客户端中的某些地址(例如aol,hotmail.com和msn)未收到
您的代码不是开始调查此问题的最佳位置 - 请先检查您的电子邮件日志和退回邮件。最可能的原因是您的电子邮件被标记为垃圾邮件。您可以通过自己设置邮箱并向其发送消息来验证这一点。如何防止您的电子邮件被标记为垃圾邮件是一个已在此处多次询问和回答的问题。
我不确定标题是否正确
如果看到生成的电子邮件和标题的示例(将其缩小到合理的大小),那将会非常有用。