I know that each part of a multipart email message can be a multipart itself. Are attachments added only as top-level parts, or can they be in a nested multipart as well?
For example of what I mean, here attachment1.doc
is nested, while attachment2.doc
would be a top-level part.
multipart/mixed |---Title: text/plain |---Text content: text/plain |---Nested multipart: multipart/mixed | |--- attachment1.doc (BASE64) |---attachment2.doc (BASE64)
I'm asking because I encountered this code from https://stackoverflow.com/a/27556667/492336:
# Iterate the different parts of the multipart message.
for part in msg.walk():
# Skip any nested multipart.
if part.get_content_maintype() == 'multipart':
continue
It's in Python, and they iterate through the different parts of the message to search for attachments, but skip any part that is itself a multipart.
Are they correct to do that? I tried reading the RFC3501, but couldn't find anything definitive saying whether file attachments can be or not be nested.