原来关键是编码类型。代替:
Content-Type: text/plain; charset="iso-8859-1"
我需要使用:
Content-Type: text/plain; charset=us-ascii
它可能取决于您如何在自己的文本编辑器中保存PHP文件的细节。我没有研究它,但是PHP中的 iconv
函数可能也给我带来了一些乐趣。所以我认为这部分确实很敏感。
$notice_text = "This is a multi-part message in MIME format.";$plain_text = "This is a plain text email.rnIt is very cool.";$html_text = "<html><body>This is an <b style='color:purple'>HTML</b> text email.rnIt is very cool.</body></html>";$semi_rand = md5(time());$mime_boundary = "==MULTIPART_BOUNDARY_$semi_rand";$mime_boundary_header = chr(34) . $mime_boundary . chr(34);$to = "Me <foo@gmail.com>";$from = "Me.com <me@me.com>";$subject = "My Email";$body = "$notice_text--$mime_boundaryContent-Type: text/plain; charset=us-asciiContent-Transfer-Encoding: 7bit$plain_text--$mime_boundaryContent-Type: text/html; charset=us-asciiContent-Transfer-Encoding: 7bit$html_text--$mime_boundary--";if (@mail($to, $subject, $body, "From: " . $from . "n" . "MIME-Version: 1.0n" . "Content-Type: multipart/alternative;n" . " boundary=" . $mime_boundary_header)) echo "Email sent successfully.";else echo "Email NOT sent successfully!";exit;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)