【发布时间】:2014-02-11 22:58:38
【问题描述】:
由 RFC822 定义的电子邮件有几个部分。我认为对于 RFC822 的不同实现应该有不同的邮件结构。那么,如何使用 imap 命令获取带有部件号的邮件结构?
我得到了一篇文章here,里面说:
Message structure
The structure of an email message is generally something like this, with part numbers:
1 - Multipart/alternative headers
1.1 - Plain text message
1.2 - HTML version of message
2 - Inline attachment, etc
In Apple Mail it's like this instead:
1 - Plain text message
2 - Multipart/alternative headers
2.1 - HTML version of the message
2.2 - Inline attachment, etc
If the message has been forwarded, then it will look like this:
1 - Multipart/alternative headers
1.1 - Plain text message
1.2 - HTML version of message
2 - Message/RFC822
2.0 - Attached message header
2.1 - Plain text message
2.2 - HTML version of message
2.3 - Inline attachment, etc
Apple Mail does it differently again, and it's more complicated. I won't bother showing it here.
例如,我想知道gmail的结构。有没有 imap 命令可以做到这一点?好吧,其他一些替代方式也可以,例如 pop 命令或其他?
【问题讨论】:
-
下载消息并通过 mime 解析器传递,或从 IMAP 获取 BODYSTRUCTURE,服务器会在其中为您解析 MIME。
-
FETCH BODYSTRUCTURE 不返回部件号。
-
它们隐含在您从响应构造的树中。它是一组嵌套列表。第一个列表是 1。第一个子列表是 1.1,第二个是 1.2,依此类推。
-
@Max 这并不总是正确的。请参阅 Jan 的回答。