Multipart MIME Types in Email — mixed, alternative, related
Understand how multipart/mixed, multipart/alternative, and multipart/related are used in email messages to combine HTML, plain text, and attachments.
Detailed Explanation
Multipart Types in Email
Email messages use multipart MIME types to combine different content representations and attachments in a single message. Understanding these types is essential for anyone building email templates or parsing email bodies.
multipart/mixed
The most common email container type. It combines different types of content in sequence:
multipart/mixed
├─ text/plain (message body)
└─ application/pdf (attachment)
Use multipart/mixed when the email has attachments.
multipart/alternative
Contains alternative versions of the same content. The email client picks the best one it can display:
multipart/alternative
├─ text/plain (fallback)
└─ text/html (rich version)
Parts are ordered from simplest to most complex. The client typically displays the last format it supports.
multipart/related
Groups content where parts reference each other, such as an HTML body with inline images:
multipart/related
├─ text/html (references cid:logo)
└─ image/png (Content-ID: <logo>)
Real-World Email Structure
A typical rich email with attachments combines all three:
multipart/mixed
├─ multipart/alternative
│ ├─ text/plain
│ └─ multipart/related
│ ├─ text/html
│ └─ image/png (inline)
└─ application/pdf (attachment)
Quick Reference
| Type | Use When |
|---|---|
multipart/mixed |
Message has attachments |
multipart/alternative |
Message has plain + HTML versions |
multipart/related |
HTML references inline images |
Use Case
Apply this knowledge when building HTML email templates with inline images and attachments, configuring email servers, or parsing raw email messages (MIME) in backend applications.
Try It — MIME Type Reference
Related Topics
multipart/form-data — File Uploads in HTTP
Multipart
text/plain vs text/html — When to Use Which
Common Types
application/octet-stream — The Generic Binary Fallback
Common Types
Choosing the Right Content-Type for REST APIs
Application Types
image/jpeg vs image/png — Choosing the Right Image Format
Image Types