← RFC Reference

RFC 2046: MIME Part 2 — Media Types

Standards Track MIME — Multipurpose Internet Mail Extensions Published November 1996
ELI5: RFC 2045 defined the envelope for email. RFC 2046 defines the types of things you can put inside: text, images, audio, video, applications — and crucially, how to put multiple things in one envelope. It is the reason a single email can contain a text body, an HTML body, and three attached files.

Why This Exists

RFC 2045 introduced Content-Type and transfer encodings, but it didn't define what content types exist or how they behave. RFC 2046 fills that gap by defining:

This is the RFC that makes modern email possible. Without it, every email would be a single block of text.

How It Works

The Top-Level Media Types

Type Description Common Subtypes
text Human-readable text text/plain, text/html, text/calendar
image Image data image/png, image/jpeg, image/gif, image/svg+xml
audio Audio data audio/mpeg, audio/ogg
video Video data video/mp4, video/webm
application Binary data or structured formats application/pdf, application/json, application/octet-stream
multipart Multiple body parts in one message multipart/mixed, multipart/alternative, multipart/related
message Encapsulated email message message/rfc822, message/delivery-status

The Multipart Mechanism

Multipart types are the heart of RFC 2046. A multipart message contains a boundary parameter that delimits each part:

Content-Type: multipart/mixed; boundary="----=_boundary_001"

------ preamble (ignored by MIME clients) ------

------=_boundary_001
Content-Type: text/plain; charset=utf-8

This is the first part.

------=_boundary_001
Content-Type: text/plain; charset=utf-8

This is the second part.

------=_boundary_001--
^^^ note the trailing -- which marks the end

Key rules for boundaries:

Multipart Subtypes

The subtype tells the mail client how to display the parts. This is where the subtlety lives.

multipart/mixed — Sequential Parts

The most common multipart type. Parts are displayed in order. Used for "message body + attachments":

Content-Type: multipart/mixed; boundary="----=_mixed"

------=_mixed
Content-Type: text/plain; charset=utf-8

Here's the report you requested.

------=_mixed
Content-Type: application/pdf; name="report.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="report.pdf"

JVBERi0xLjQKJeLjz9MK...

------=_mixed--

multipart/alternative — Same Content, Different Formats

Contains multiple versions of the same content. The mail client picks the best one it can display. Parts are ordered from simplest to richest — the last part is preferred:

Content-Type: multipart/alternative; boundary="----=_alt"

------=_alt
Content-Type: text/plain; charset=utf-8

Welcome to our service!

------=_alt
Content-Type: text/html; charset=utf-8

<h1>Welcome to our service!</h1>
<p>We're glad to have you.</p>

------=_alt--

This is how every well-formed HTML email works: the text/plain fallback comes first, the text/html version comes last. A client that supports HTML displays the HTML; a plaintext client displays the text.

multipart/related — Linked Parts

Used when parts reference each other. The most common use case is HTML email with inline images. The HTML references images by Content-ID (cid: URLs):

Content-Type: multipart/related; boundary="----=_rel"

------=_rel
Content-Type: text/html; charset=utf-8

<p>Check out our logo:</p>
<img src="cid:logo@example.com" alt="Logo" />

------=_rel
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-ID: <logo@example.com>

iVBORw0KGgoAAAANSUhEU...

------=_rel--

multipart/digest — Collection of Messages

A variant of mixed where the default content type for each part is message/rfc822 instead of text/plain. Used by mailing list digests. Rarely seen in modern email.

Key Technical Details

Nesting Multipart Types

The real power of MIME comes from nesting. A typical marketing email with inline images and an attachment looks like this:

; The standard structure for HTML email with inline images + attachments

Content-Type: multipart/mixed           ← outer: body + attachments
  |
  |-- multipart/alternative              ← body: text or HTML
  |     |-- text/plain                    ← plaintext fallback
  |     |-- multipart/related             ← HTML + inline images
  |           |-- text/html               ← the HTML body
  |           |-- image/png (cid:logo)    ← inline image
  |
  |-- application/pdf (attachment)       ← file attachment

This three-level nesting is the standard pattern used by virtually every email library and email service provider.

The message/rfc822 Type

Encapsulates an entire email message as a body part. Used for forwarding messages as attachments and in bounce notifications (RFC 3462 multipart/report). The encapsulated message has its own headers (From, To, Subject, etc.) and body.

The application/octet-stream Fallback

When the content type of a file is unknown, use application/octet-stream. This tells the client to treat it as generic binary data and typically triggers a download prompt. It is the MIME equivalent of "I don't know what this is; save it and figure it out yourself."

Boundary Requirements

The boundary string has specific rules:

Common Mistakes

Deliverability Impact

Related RFCs