简体   繁体   English

在Python中使用imaplib提取完整电子邮件标头

[英]Extract Full Email header using imaplib in Python

I am trying to extract the entire email header using imaplib in Python. 我正在尝试在Python中使用imaplib提取整个电子邮件标头。 At the momment I am using the line below which provides subject, From, To and Date etc but seems to be missing a lot of data compared to when I view the original message in gmail. 暂时,我正在使用下面的行,其中提供了主题,发件人,收件人和日期等,但是与我在gmail中查看原始消息相比,似乎丢失了很多数据。

  email_header = imapSession.fetch(1, '(RFC822.HEADER)')

I would like to include the full email header with items such as the received locations like below: 我想将完整的电子邮件标头包含在项目中,例如如下所示的接收位置:

Received: from [136.167.40.119] (HELO dc.edu) by fe3.dc.edu (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 61258719 for example_to@mail.dc.edu; 收到:fe3.dc.edu(CommuniGate Pro SMTP 4.1.8)从[136.167.40.119](HELO dc.edu)中获得,例如E_SMTP-TLS ID为61258719;例如:_to@mail.dc.edu; Mon, 23 Aug 2004 11:40:10 -0400 2004年8月23日星期一11:40:10 -0400

Is this possible with imaplib? imaplib是否可以?

Thanks in advance 提前致谢

RFC822.HEADER should give you the full headers. RFC822.HEADER应该为您提供完整的标题。 If you are seeing otherwise, the server is broken. 如果您看到其他情况,则表明服务器已损坏。 (More likely you are testing with a message which doesn't have the headers you expect.) (很有可能您正在测试的消息中没有您期望的标题。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM