Multi part mime email

A blast from the past!

A multi-part MIME email is an email that contains multiple parts, each with a different content type, such as text, HTML, and attachments. This allows the email to be displayed and rendered correctly by different email clients and devices.

Here's a breakdown of the different parts of a multi-part MIME email:

  1. Text part: This is the plain text version of the email, which is usually used as a fallback for email clients that don't support HTML or have limited rendering capabilities.
  2. HTML part: This is the HTML version of the email, which contains formatting and layout information. This part is used by email clients that support HTML.
  3. Attachments: These are files that are attached to the email, such as images, documents, or other files.

The email is encoded using the Multipurpose Internet Mail Extensions (MIME) standard, which allows for the inclusion of multiple parts with different content types. The email is typically sent with a Content-Type header that specifies the type of each part, such as text/plain for the text part and text/html for the HTML part.

Here's an example of what a multi-part MIME email might look like:

From: John Doe <[email protected]>
To: Jane Smith <[email protected]>
Subject: Test Email

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============1234567890=="

--===============1234567890==
Content-Type: text/plain

Hello, this is the text part of the email.

--===============1234567890==
Content-Type: text/html

<html>
  <body>
    <p>Hello, this is the HTML part of the email.</p>
  </body>
</html>
--===============1234567890==
Content-Type: application/octet-stream; name="example.txt"
Content-Disposition: attachment; filename="example.txt"

This is an example attachment.

--===============1234567890==

In this example, the email has three parts:

  1. The text part, which is the plain text version of the email.
  2. The HTML part, which is the HTML version of the email.
  3. The attachment, which is a file named "example.txt".

The email is encoded using the multipart/mixed content type, which indicates that the email contains multiple parts with different content types. The boundary parameter specifies the boundary between each part, which is used by email clients to separate the different parts of the email.