Search code examples
emailmime-typesmultipart

MIME: multipart in multipart


I am Writing a little Mail parser for a project and to understand mail better.

There came up a question about Multiparts.

When I have a Mail with Content-Type: multipart/alternative oder any other multipart with a divider, will it be possible that in that multipart is anoter multipart (e.g. a multipart/mixed) or the oter way. What divider does that have, has that an own divider?

So is the MIME-Type multipart/* a flat structure (Can be parsed using one splitting divider) or is it a tree (Where each splitted part could be splitted again).


Solution

  • After 3 long nights of programming and intensive testing, I recognized, that multipart/* is NOT flat. It is a tree structure. For example if you have a html and a plaintext part as well as attachments, the mail is multipart/mixed holding the attachments and a multipart/alternative part. If there are also Inline-Images, the HTML-Part could be multipart/related holding the Images and the html.