0

When I fetch data using imaplib

rv, data = imap.fetch("1", '(RFC822)')

I get response of the following shape

[(b'1 (RFC822 {35661}',
  b'Delivered-To: ... here goes the message' ),
  b')']

What is the rationale here? Why opening (b'1 (RFC822 {35661}' is part of the first tuple, but closing b')' is a separate element?

AcK
  • 2,063
  • 2
  • 20
  • 27

1 Answers1

0

There's only one explanation I can think of. The closing b')' also shows any flags if they exist.

Eg: b' FLAGS (\\Seen))' (from an email I received).

Such flags either:

  1. aren't from the message source obviously and are therefore arranged separately, or
  2. can be easily extracted to decide on an action before having to read the entire message source.

That's my best guess, I might be way off base. It definitely is odd.

gandhiv
  • 61
  • 4