0

I am trying to extract the entire email header using imaplib in Python. 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.

  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; Mon, 23 Aug 2004 11:40:10 -0400

Is this possible with imaplib?

Thanks in advance

user5298729
  • 105
  • 1
  • 2
  • 6

1 Answers1

0

RFC822.HEADER should give you the full headers. 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.)

tripleee
  • 175,061
  • 34
  • 275
  • 318