HOW to get mail structure with part number using i

2019-07-06 05:12发布

There are several parts for an email which is defined by RFC822. I think that there should be different stuctures of a mail for different implementation of RFC822. Well, how to get mail structure with part numbers using imap command?

I have get an article here, which is said:

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.

For example, I want to know the structure of gmail. Is there any imap commands can doing this? well, some other alternative way will be fine either, such as pop command or something else?

标签: email imap
1条回答
你好瞎i
2楼-- · 2019-07-06 05:46

You are looking for the FETCH (BODYSTRUCTURE) command. It will not include any numbers because that piece of information is implicitly present -- an IMAP client is supposed to parse the BODYSTRUCTURE data and infer the actual part number from the resulting data structure. Just look at the offset of the interesting part.

It's a bit more complicated due to the way certain parts are specified to not be directly numbered; i.e. a multipart/* which consitutes the body of a message/rfc822 does not get its own number, but is instead accessible as number-of-its-parent.TEXT.

查看更多
登录 后发表回答