MIME multipart structure

Use valid MIME types, boundaries, transfer encodings, and multipart nesting so every client can select a safe representation.

What it is

MIME adds typed body parts, character sets, transfer encodings, attachments, and multipart containers to Internet messages.

Why it matters

Clients need MIME structure to choose HTML or plain text, display inline images, and handle attachments without corrupting binary data.

How to implement

Use multipart/alternative for equivalent plain-text and HTML bodies, ordered from least to most faithful. Wrap alternatives and attachments in multipart/mixed. Generate unique boundaries and declare a character set for text parts.

Common mistakes

  • Using multipart/mixed for equivalent alternatives.
  • Declaring UTF-8 while sending another encoding.
  • Referring to a Content-ID that has no matching inline part.

Verification

Parse the delivered source and draw the MIME tree. Open it in a text-only client and a graphical client; each must select the intended representation.

Sources

  1. RFC 2045 — Multipurpose Internet Mail Extensions — IETF
  2. RFC 2046 — Media types and multipart bodies — IETF