【问题标题】:multipart/mixed email. Comes with empty body. What's wrong?多部分/混合电子邮件。带有空的身体。怎么了?
【发布时间】:2009-12-10 11:03:08
【问题描述】:

发送电子邮件:

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 - 同样的故事)

【问题讨论】:

    标签: php email content-type multipart


    【解决方案1】:

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

    还要注意,在最后一个边界处,您必须再添加两个连字符来表示它是结尾。

    示例取自维基百科,参见here

    【讨论】:

    • 是的,就是这样。前导和尾随连字符。 THX 伙计们
    【解决方案2】:

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

    边界应该是这样的

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

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

    另一方面,邮件结束边界应该看起来像

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

    (同样,查看任何邮件消息的来源。当然,或者阅读 RFC :))。

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

    【讨论】:

    • afaik 边界无关紧要。无论如何,我试图改变 - 它没有帮助
    • 我同意@Tomasz:不正确的最终边界可能是导致问题的原因。 MIME 解析器不知道何时结束。
    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 2014-11-28
      • 2015-11-25
      • 1970-01-01
      • 1970-01-01
      • 2015-12-15
      • 2015-05-03
      • 1970-01-01
      • 2018-07-11
      相关资源
      最近更新 更多