如何使用imap命令获取带有部件号的邮件结构

时间:2014-01-22 03:21:59

标签: email imap

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命令或别的什么?

1 个答案:

答案 0 :(得分:3)

您正在寻找FETCH (BODYSTRUCTURE)命令。它不包含任何数字,因为隐含地存在这条信息 - IMAP客户端应该解析 BODYSTRUCTURE数据并从结果数据结构中推断出实际的部件号。只要看看有趣部分的偏移量。

由于某些部分被指定为而不是直接编号的方式,它有点复杂;即multipart/*构成message/rfc822的主体,得到自己的号码,但可以作为其父亲的号码 .TEXT

相关问题