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?
"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.
Try IMAP4.fetch(message_set, "BODYSTRUCTURE")
IMAP4.fetch(message_set, "BODYSTRUCTURE")
For more on FETCH BODYSTRUCTURE's answer, read RFC3501 .