【发布时间】:2010-05-18 03:50:18
【问题描述】:
我想知道如何以正确的顺序构建 SMTP 多部分消息,以便它能够在 iPhone 邮件客户端上正确呈现(在 GMail 中正确呈现)。
我正在使用 Javamail 构建包含以下部分的电子邮件:
- 内容类型为“text/html; UTF-8”的正文部分
- 嵌入式图片附件。
- 文件附件
我通过 GMail SMTP(通过 SSL)发送邮件,并且使用 GMail 帐户正确发送和呈现邮件,但是,邮件无法在 iPhone 邮件客户端上正确呈现。在 iPhone 邮件客户端上,图像会在“Before Image”文本之前渲染,而它应该在之后渲染。在“图片前”文本之后有一个带问号的图标(我认为这意味着它找不到引用的 CID)。我不确定这是 iPhone 邮件客户端的限制还是我的邮件发送代码中的错误(我强烈假设是后者)。
我认为我的部件上的标题可能不正确,或者我提供的多部件顺序错误。我将接收到的邮件的文本包含在 gmail 的输出中(它使文件正确
Message-ID: <3977333.1.1274154021787.JavaMail.Chris@smtp.gmail.com>
Subject: =?UTF-8?Q?Test_from_=E3=82=AF=E3=83=AA=E3=82=B9?=
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_0_20870565.1274154021755"
------=_Part_0_20870565.1274154021755
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-ID: <20100518124021763_368238_0>
iVBORw0K ----- TRIMMED FOR CONCISENESS
6p1VVy4alAAAAABJRU5ErkJggg==
------=_Part_0_20870565.1274154021755
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
<html><head><title>Employees Favourite Foods</title>
<style>
body { font: normal 8pt arial; }
th { font: bold 8pt arial; white-space: nowrap; }
td { font: normal 8pt arial; white-space: nowrap; }
</style></head><body>
Before Image<br><img src="cid:20100518124021763_368238_0">
After Image<br><table border="0">
<tr>
<th colspan="4">Employees Favourite Foods</th>
</tr>
<tr>
<th align="left">Name</th><th align="left">Age</th><th align="left">Tel.No</th><th align="left">Fav.Food</th>
</tr>
<tr style="background-color:#e0e0e0">
<td>Chris</td><td>34</td><td>555-123-4567</td><td>Pancakes</td>
</tr>
</table></body></html>
------=_Part_0_20870565.1274154021755
Content-Type: text/plain; charset=us-ascii; name=textfile.txt
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=textfile.txt
This is a textfile with numbers counting from one to ten beneath this line:
one
two
three
four
five
six
seven
eight
nine
ten(no trailing carriage return)
------=_Part_0_20870565.1274154021755--
即使您不能帮助我,如果论坛的任何成员可以向我转发包含内联图像(但不是外部超链接图像)的(非个人)邮件,我将不胜感激。我只需要找到一个工作样本,然后我就可以跳过这个。
谢谢,
克里斯。
【问题讨论】:
标签: java iphone smtp jakarta-mail