从邮件中删除的内容()
问题描述:
我有一封电子邮件,我试图发送(整个电子邮件在标题中)。其实,电子邮件正在发送。但是当它到达目的地时,内容已被删除。如果我发送完全相同的电子邮件,并使用来自不同服务器的相同代码构建,则一切正常。从邮件中删除的内容()
当我把它打印出来使用nl2br(htmlspecialchars($headers, ENT_QUOTES))
,这就是我得到:
From: [email protected]
Reply-to: [email protected]
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="cccf6094979eaede770a2a2e88fc83e9"
Content-Transfer-Encoding: 7bit
This is a MIME encoded message.
--cccf6094979eaede770a2a2e88fc83e9
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
You are not being awesome....
--cccf6094979eaede770a2a2e88fc83e9--
当电子邮件被发送,身体是空的,当我看着它在Gmail的“秀原来,”它看起来一样,但内容不在那里。
我正在使用postfix和OpenDKIM,但我已禁用它们中的每一个,甚至切换回sendmail,并且这些电子邮件都没有机构。我正在为这件事撕碎我的头发。
答
您缺少邮件正文中的空白行。
报价from the RFC:
每个部分用包封边界启动,然后包含一个主体部分包括标题区域,一个空行和主体区的。
(重点煤矿)
添加适当的空行和它的作品:
页眉:
From: [email protected]
Reply-to: [email protected]
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="cccf6094979eaede770a2a2e88fc83e9"
Content-Transfer-Encoding: 7bit
身体:
This is a MIME encoded message.
--cccf6094979eaede770a2a2e88fc83e9
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
You are not being awesome....
--cccf6094979eaede770a2a2e88fc83e9--
+0
就是这样。这是一个缩小的例子;我们的图书馆(一年前)适应于基于此回答处理附件:http://stackoverflow.com/a/12313090。我已经改变它打破标题和正文,并且它正常工作。谢谢! – Kittsil
你检查你的邮件日志为postfix或sendmail?那里有什么有趣的东西? – Jason
您缺少邮件正文中的空白行。请参阅[示例](https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html):“每个部分以封装边界开始,然后包含由标题区域组成的正文部分,**空格线**和身体区域。“ –
@Jason我找不到任何相关的东西;只需连接Google的邮件服务器即可。 – Kittsil