RFC 1521 - MIME (Multipurpose Internet Mail Extensions)

This section provides a summary of 'RFC 1521 - MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies' and how the Base64 encoding algorithm was adopted in this RFC.

As background information, let's take a look at the RFC (Request For comments) paper in which the Base64 encoding algorithm was adopted as part of the MIME standard. In 1993, N. Borenstein and others submitted "RFC 1521 - MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies". In this RFC, N. Borenstein and others proposed to use the Base64 encoding as one of the content transfer encodings.

In this RFC, 2 content transfer encodings were proposed:

Content-Transfer-Encoding 1: Quoted-Printable - This encoding reserves the equal sign "=" as the encoding escape character. Generally, any non-printable character (8-bit octet), or the equal sign "=" must be encoded in the form of "=XX", where XX is the two digit hexadecimal representation of the octet's value. For example, a CRLF (Carriage Return Line Feed) sequence will be encoded as "=0D=0A".

Content-Transfer-Encoding 2: Base64 - This encoding was adopted from "RFC 1421 Privacy Enhancement for Internet Electronic Mail: Part I: Message Encryption and Authentication Procedures" as is with one change on the encoded output folding length from 64 characters to 76 characters.

This RFC also suggested that Base64 is preferred encoding over quoted-printable for binary data.

Here is an example of email message with a multi-part content using Quoted-Printable and Base64 encodings for different parts taken from kb.datamotion.com:

MIME-Version: 1.0
X-Mailer: MailBee.NET 8.0.4.428
Subject: test subject
To: kevinm@datamotion.com
Content-Type: multipart/mixed;
       boundary="XXXXboundary text"

--XXXXboundary text
Content-Type: multipart/alternative;
       boundary="XXXXboundary text"

--XXXXboundary text
Content-Type: text/plain;
       charset="utf-8"
Content-Transfer-Encoding: quoted-printable

This is the body text of a sample message.
--XXXXboundary text
Content-Type: text/html;
       charset="utf-8"
Content-Transfer-Encoding: quoted-printable
<pre>This is the body text of a sample message.</pre>

--XXXXboundary text
Content-Type: text/plain;
name="log_attachment.txt"
Content-Disposition: attachment;
filename="log_attachment.txt"
Content-Transfer-Encoding: base64

TUlNRS1WZXJzaW9uOiAxLjANClgtTWFpbGVyOiBNYWlsQmVlLk5FVCA4LjAuNC40MjgNClN1Ympl
Y3Q6IHRlc3Qgc3ViamVjdA0KVG86IGtldmlubUBkYXRhbW90aW9uLmNvbQ0KQ29udGVudC1UeXBl
OiBtdWx0aXBhcnQvYWx0ZXJuYXRpdmU7DQoJYm91bmRhcnk9Ii0tLS09X05leHRQYXJ0XzAwMF9B
RTZCXzcyNUUwOUFGLjg4QjdGOTM0Ig0KDQoNCi0tLS0tLT1fTmV4dFBhcnRfMDAwX0FFNkJfNzI1
RTA5QUYuODhCN0Y5MzQNCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsNCgljaGFyc2V0PSJ1dGYt
OCINCkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IHF1b3RlZC1wcmludGFibGUNCg0KdGVzdCBi
b2R5DQotLS0tLS09X05leHRQYXJ0XzAwMF9BRTZCXzcyNUUwOUFGLjg4QjdGOTM0DQpDb250ZW50
LVR5cGU6IHRleHQvaHRtbDsNCgljaGFyc2V0PSJ1dGYtOCINCkNvbnRlbnQtVHJhbnNmZXItRW5j
b2Rpbmc6IHF1b3RlZC1wcmludGFibGUNCg0KPHByZT50ZXN0IGJvZHk8L3ByZT4NCi0tLS0tLT1f
TmV4dFBhcnRfMDAwX0FFNkJfNzI1RTA5QUYuODhCN0Y5MzQtLQ0K

--XXXXboundary text--

For more information, visit RFC 1521 Website at https://tools.ietf.org/html/rfc1521.

Table of Contents

 About This Book

Base64 Encoding

 Base64 Encoding Algorithm

 RFC 1421 - Privacy Enhancement for Email

RFC 1521 - MIME (Multipurpose Internet Mail Extensions)

 W3C Implementation of Base64 in Java

 Sun Implementation of Base64 in Java

 Sun Implementation of Base64 in Java - Test

 Goetz' Implementation of Base64 in JavaScript

 Goetz' Implementation of Base64 in JavaScript - Test

 Base64 Encoding and Decoding Tools

 Base64URL - URL Safe Base64 Encoding

 Base32 Encoding

 URL Encoding, URI Encoding, or Percent Encoding

 UUEncode Encoding

 References

 Full Version in PDF/EPUB