【问题标题】:HOW to get mail structure with part number using imap command如何使用 imap 命令获取带有部件号的邮件结构
【发布时间】: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 的回答。

标签: email imap


【解决方案1】:

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

由于某些部分被指定为直接编号的方式,它有点复杂;即构成message/rfc822 主体的multipart/* 确实没有 获得自己的号码,而是可以作为number-of-its-parent.TEXT 访问.

【讨论】:

猜你喜欢
  • 2014-03-22
  • 2022-08-08
  • 1970-01-01
  • 2015-07-17
  • 2019-02-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-31
相关资源
最近更新 更多