且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过php mail()从邮件中删除的内容

更新时间:2023-02-22 23:05:07

您的邮件正文中缺少空白行。



引用从RFC : p>


每个部分以封装边界开始,然后包含一个正文部分,由标题区域空白行组成,和一个身体区域。


(Emphasis mine)



添加适当的空白行,它的作品:



标题:

 从:kittsil@example.com 
回复:kittsil@example.com
MIME版本:1.0
内容类型:multipart / mixed; border =cccf6094979eaede770a2a2e88fc83e9
内容转移编码:7bit

正文:

 这是一个MIME编码的消息。 

--cccf6094979eaede770a2a2e88fc83e9
内容类型:text / plain; charset =iso-8859-1
内容转移编码:8bit

你不是很棒....
--cccf6094979eaede770a2a2e88fc83e9--


I have an email that I am trying to send (the entire email is in the headers). Actually, the email is sending. But when it gets to the destination, the content has been removed. If I send the exact same email, built by the same code from a different server, everything works great just great.

When I print it out using nl2br(htmlspecialchars($headers, ENT_QUOTES)), this is what I get:

From: kittsil@example.com
Reply-to: kittsil@example.com
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--

When the email is delivered, the body is empty, and when I look at it in Gmail's "show original," it looks the same, but the content is not there.

I am using postfix and OpenDKIM, but I have disabled each of them, and even switched back to sendmail, and none of those emails have bodies. I'm ripping my hair out about this.

You are missing blank lines in your mail body.

Quote from the RFC:

Each part starts with an encapsulation boundary, and then contains a body part consisting of header area, a blank line, and a body area.

(Emphasis mine)

Add the proper blank lines and it works:

Header:

From: kittsil@example.com
Reply-to: kittsil@example.com
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="cccf6094979eaede770a2a2e88fc83e9"
Content-Transfer-Encoding: 7bit

Body:

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--