2

发送电子邮件:

From: <...>
X-Mailer: SnowBoss
Reply-To: <...>
X-Priority: 3 (Normal)
Message-ID: <248.20091210135259@snowman2010.com>
To: <...>
Subject: =?UTF-8?B?0JzQntCZIFNVQkpFQ1Q=?=
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----------A4D921C2D10D7DB"

This is a multi-part message in MIME format.

----------A4D921C2D10D7DB
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

MY TEXT
----------A4D921C2D10D7DB
Content-Type: text/html;
charset=utf-8
Content-Transfer-Encoding: 8bit

<html><b>BOLD</b></html>
----------A4D921C2D10D7DB
.

<250 Data received OK. //server response

它带有空的身体。这只发生在multipart/mixed内容上(尝试过multipart/alternative- 相同的故事)

4

3 回答 3

5

正如 Tomasz 所提到的,在您使用边界的那一行,您的边界分隔符的开头必须有两个连字符。检查以下内容:

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="frontier"

This is a message with multiple parts in MIME format.
--frontier
Content-Type: text/plain

This is the body of the message.
--frontier
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64

PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg
Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==
--frontier--

另请注意,在最后一个边界处,您必须添加另外两个连字符以表示它是结尾。

示例取自 Wikipedia,请参见此处

于 2009-12-10T12:03:52.420 回答
3

我猜你可能有错误的边界设置。

边界应该看起来像

Content-Type: multipart/alternative; boundary="--------A4D921C2D10D7DB"

含义 - 包含两个'-' 字符。查看任何电子邮件的来源。

另一方面,邮件结束边界可能看起来像

----------A4D921C2D10D7DB--

(再次,请参阅任何邮件消息的来源。或者阅读 RFC,当然 :))。

我鼓励您使用现有的邮件程序类,例如Swift MailerPHPMailer。为什么要重新发明轮子?

于 2009-12-10T11:57:05.597 回答
1

我猜你的意思是“这是一条 MIME 格式的多部分消息”。作为内容粘贴片段中的正文。当内容类型设置为 mimepart/alternate 或 mimepart/mixed 时,是否呈现正文取决于电子邮件客户端。几乎所有客户都展示了身体部位。

于 2012-05-29T11:56:59.927 回答