Skip to content
uencoder

MIME Encoding

MIME (Multipurpose Internet Mail Extensions) encoding defines the mechanisms for transporting non-ASCII text and binary attachments in email, including the Base64 and Quoted-Printable content transfer encodings.

Purpose

It extends the SMTP protocol, which originally supported only 7-bit ASCII, so it can carry arbitrary byte streams and multilingual text.

Mechanism

The Content-Transfer-Encoding header declares the encoding: 7bit/8bit/binary pass data through; base64 encodes arbitrary binary; quoted-printable escapes only non-printable characters. The Content-Type header declares the MIME type and boundaries.

Use cases

  • Email attachment transport
  • HTTP multipart/form-data uploads
  • Usenet binary attachments
  • S/MIME encrypted mail

Examples

  • Input
    Content-Transfer-Encoding: base64
    Output
    SGVsbG8=

    The body is Base64-encoded as declared

Common errors

Decoding a MIME attachment while ignoring the Content-Transfer-Encoding header
Decode according to the header first, then interpret the result using the charset

Related terms

Related tools

References