Multipart Content Types in Open Email Standards
To fully leverage the benefits of HTML5 within emails, the recommended approach is to use the multipart/alternative content type. This ensures compatibility across email clients by providing fallback options like text/plain or text/html, while also enabling richer content and a clear distinction between HTML4 and HTML5 to render the most appropriate version.
For emails containing inline images, use the multipart/related content type along with application/xhtml+xml. These embed assets should be referenced via cid (Content-ID) for secure rendering. Only images should be allowed; other assets like stylesheets or scripts introduce security risks and must be blocked.
Example 1: Complete multipart/alternative Email
Content-Type: multipart/alternative; boundary="boundary42"
--boundary42
Content-Type: text/plain; charset="UTF-8"
This is the plain text version.
--boundary42
Content-Type: text/html; charset="UTF-8"
<html>
<body>
<p>This is the <strong>HTML4</strong> version.</p>
</body>
</html>
--boundary42
Content-Type: application/xhtml+xml; charset="UTF-8"
<!doctype html>
<html>
<body>
<p>This is the <strong>HTML5</strong> version.</p>
</body>
</html>
--boundary42--
Example 2: Inline Images with multipart/related
Content-Type: multipart/related; boundary="boundary42"
--boundary42
Content-Type: application/xhtml+xml; charset="UTF-8"
<!doctype html>
<html>
<body>
<p>This email includes an inline image:</p>
<img src="cid:logo1" alt="Logo" />
</body>
</html>
--boundary42
Content-Type: image/png
Content-ID: <logo1>
Content-Transfer-Encoding: base64
[Base64 image data]
--boundary42--
Example 3: Combining multipart/alternative and multipart/related
Content-Type: multipart/alternative; boundary="boundary1"
--boundary1
Content-Type: text/plain; charset="UTF-8"
Plain text version of the email.
--boundary1
Content-Type: text/html; charset="UTF-8"
<html>
<body>
<p>HTML4 version of the email.</p>
</body>
</html>
--boundary1
Content-Type: multipart/related; boundary="boundary2"
Content-Disposition: inline
--boundary2
Content-Type: application/xhtml+xml; charset="UTF-8"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE email SYSTEM "https://openstandards.email/dtd/email.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<p>HTML5 version with inline image:</p>
<img src="cid:logo1" alt="Logo" />
</body>
</html>
--boundary2
Content-Type: image/png
Content-ID: <logo1>
Content-Transfer-Encoding: base64
[Base64 image data]
--boundary2--
--boundary1--

