MIME php邮件仅显示文本/纯文本版本[关闭]
Posted
技术标签:
【中文标题】MIME php邮件仅显示文本/纯文本版本[关闭]【英文标题】:MIME php mail only showing text/plain version [closed] 【发布时间】:2013-02-17 19:20:13 【问题描述】:我尝试发送多部分/替代电子邮件,因此我在一封邮件中发送文本版本和 html 版本。我的问题是邮件只包含这个纯文本:
邮件在这里:
Multipart Message coming up
--b4d67c224c82d8fad38c0bcef1a0bf97Content-Type: text/plain; charset=iso-8859-1Content-Transfer-Encoding: 7bitYou really ought remember the birthdays--b4d67c224c82d8fad38c0bcef1a0bf97Content-Type: text/html; charset=iso-8859-1Content-Transfer-Encoding: 7bit<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
</body>
</html>
--b4d67c224c82d8fad38c0bcef1a0bf97--
代码如下所示。
<?
//this is a path to php mailer class you have dowloaded
$to = "mail@mydomain.com";
$boundary = md5(date('U'));
$subject = "My Subject";
$headers = "From: mail@mydomain.com" . "\r\n".
"X-Mailer: PHP/".phpversion() ."\r\n".
"MIME-Version: 1.0" . "\r\n".
"Content-Type: multipart/alternative; boundary=$boundary". "\r\n".
"Content-Transfer-Encoding: 7bit". "\r\n";
$text = "You really ought remember the birthdays";
$html = '<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
</body>
</html>
';
$message = "Multipart Message coming up" . "\r\n\r\n".
"--".$boundary.
"Content-Type: text/plain; charset=iso-8859-1" .
"Content-Transfer-Encoding: 7bit".
$text.
"--".$boundary.
"Content-Type: text/html; charset=iso-8859-1".
"Content-Transfer-Encoding: 7bit".
$html.
"--".$boundary."--";
mail($to, $subject, $message, $headers);
?>
【问题讨论】:
【参考方案1】:您没有用“\n”终止边界和内容行
根据 mime 规范强制
【讨论】:
以上是关于MIME php邮件仅显示文本/纯文本版本[关闭]的主要内容,如果未能解决你的问题,请参考以下文章
使用 mailkit 发送的多部分电子邮件的文本/纯文本版本未正确接收