Understanding multipart email structure and MIME format
Multipart emails are structured using MIME (Multipurpose Internet Mail Extensions) format with multiple parts separated by MIME boundaries. Structure includes: MIME headers (Content-Type: multipart/alternative, multipart/mixed, etc.), MIME boundaries (unique strings separating parts), multiple parts (HTML part, plain text part, attachment parts), and part headers (Content-Type, Content-Disposition, Content-Transfer-Encoding for each part).
Multipart/alternative contains HTML and plain text alternatives. Multipart/mixed contains text and attachments. Multipart/related contains HTML and inline images. Email clients parse MIME boundaries to identify and display appropriate parts.
Learn more about MIME in email and analyze email source code using our email source analyzer.
Multipart emails start with MIME headers specifying multipart content type and boundary:
Content-Type: multipart/alternative; boundary="boundary-string"Content-Type: multipart/mixed; boundary="boundary-string"MIME boundaries separate parts. Boundaries are unique strings that mark the start and end of each part.
Each part contains: part headers (Content-Type, Content-Disposition, Content-Transfer-Encoding), blank line, and part content.
Parts are ordered by importance. Email clients typically display the first compatible part.
Different multipart types serve different purposes:
Contains alternative versions of the same content (HTML and plain text). Email clients choose which version to display based on capabilities.
Contains mixed content (text and attachments). All parts are displayed together.
Contains related content (HTML and inline images). Parts are related and displayed together.
Contains signed content (message and signature). Used for email authentication (DKIM).
Multipart emails can be nested (multipart/mixed containing multipart/alternative) for complex email structures.
MIME boundaries are unique strings that separate different parts in multipart emails. Boundaries mark the start and end of each part.
Boundaries are specified in Content-Type headers: Content-Type: multipart/alternative; boundary="unique-boundary-string"
Boundaries appear before each part (except the first): --boundary-string and after the last part: --boundary-string--
Email clients parse MIME boundaries to identify and extract different parts for display.
Boundaries must be unique within each email to ensure proper parsing.
Email clients select which part to display based on client capabilities and user preferences (HTML vs plain text).
Clients parse MIME boundaries to identify and extract different parts for display.
Clients display appropriate parts: HTML content for clients with HTML support, plain text for clients without HTML support.
Clients extract and display attachments from multipart/mixed messages separately.
Clients handle missing or invalid parts by displaying available parts or falling back to plain text.