Is it possible to check if the email contains the attachment only from the email header?

I am developing a mail client in Python.

Is it possible to check if an email attachment is only from the email header without downloading all the email?

+4
source share
2 answers

"attachment" is a fairly broad term. Is the image for the HTML message attached?

In general, you can try to parse the header of the content type. If it is multipart / mixed, most likely the message contains an attachment.

+5
source

Try IMAP4.fetch(message_set, "BODYSTRUCTURE")

For more on FETCH BODYSTRUCTURE's answer, read RFC3501 .

+7
source

All Articles