0

我的目标是修改 MIME 内容并在电子邮件中添加页脚注释,而不改变其行为。

如果电子邮件内容内容类型是文本/纯文本,那么我将电子邮件内容类型更新为多部分/混合,如下所示:

Content-Type: multipart/mixed;
Boundary="--=_SAMPLE_MIME_BOUNDARY_"

email original data

----=_SAMPLE_MIME_BOUNDARY_
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit

!-- Sample footer note --!
----=_SAMPLE_MIME_BOUNDARY_--

如果电子邮件内容类型默认为多部分/混合,那么我正在更新的电子邮件内容如下:

Content-Type: multipart/mixed;
boundary="----=_SAMPLE_MIME_BOUNDARY_"

------=_SAMPLE_MIME_BOUNDARY_
Content-Type: text/plain;
Content-Transfer-Encoding: 8bit

email data

------=_SAMPLE_MIME_BOUNDARY_
Content-Type: application/octet-stream;
name="test_attachment"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test_attachment"

<<attachment data>>

------=_SAMPLE_MIME_BOUNDARY_
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit;
Content-Disposition: inline;

!-- Sample footer note --! 
------=_20160127171644_62291--

但是当我更新电子邮件正文时,Outlook 会将示例注释视为附件。如果是 Thunderbird,当我单击转发电子邮件时,它会将页脚视为附件。

所以我的问题是,在电子邮件中添加页脚文本的最佳方法是什么?我做得对吗?如果有任何问题,建议更改/确定。

4

1 回答 1

0

您的邮件的 MIME 结构是错误的。它需要是

multipart/mixed
    multipart/alternative
        text/plain
        text/html
    application/octet-stream
于 2016-01-28T14:11:19.393 回答