
MIME (Multipurpose Internet Mail Extensions) provides conventions for describing and packaging message content. Its media types also identify formats on the web: an HTTP response can declare HTML, an image, a PDF, or another kind of data through Content-Type.
Read a media type
A media type normally has a type and subtype separated by a slash. Optional parameters add information. In text/html; charset=utf-8, text is the type, html is the subtype, and charset identifies the character encoding.
| Value | Typical content | Useful distinction |
|---|---|---|
text/plain | Plain text | Characters are presented as text rather than HTML elements. |
text/html | HTML document | The browser interprets markup as a document. |
image/jpeg | JPEG image | A .jpg or .jpeg filename commonly accompanies this type. |
application/pdf | PDF document | Viewing behavior also depends on client settings and disposition. |
application/json | JSON data | The body should follow JSON syntax. |
multipart/mixed | A body containing separately described parts | A boundary separates the parts. |
The IANA media-type registry records registered names. A filename extension is a naming convention; Content-Type is a message declaration; the actual bytes have their own format. Check all three when a file behaves unexpectedly.
Follow a multipart message
This simplified MIME body contains a text note and a text attachment. Delivery headers such as From and To are omitted because this is an anatomy example, not an email to send.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="practice-boundary"
--practice-boundary
Content-Type: text/plain; charset=utf-8
Here is the fictional note.
--practice-boundary
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="note.txt"
Remember to return the atlas.
--practice-boundary--The outer Content-Type announces the multipart container and names its boundary. Each delimiter begins with two hyphens followed by that boundary. The final delimiter adds two more hyphens to close the container. Each part has its own headers, a blank line, and content.
RFC 2046 defines multipart organization. Mixed groups separate parts together; alternative supplies different representations of the same information, such as plain text and HTML. A mail client chooses a representation it supports. Nesting these structures lets a message offer alternatives while also carrying attachments.
The filename suggests how an attachment should be named when saved. The Content-Disposition specification distinguishes attachment and inline presentation and treats supplied filenames as information the receiving software must handle carefully.
Separate format, encoding, and encryption
MIME transfer encodings such as base64 represent data in a form suitable for message transport. They do not change a JPEG into a different image format. The receiver decodes the representation before using the original bytes. The MIME format specification defines Content-Type and Content-Transfer-Encoding.
Base64 is reversible encoding, not secrecy: anyone with the encoded content can decode it. In HTTP, Content-Encoding commonly describes compression; it serves a different role from email's Content-Transfer-Encoding. Keep these fields distinct when debugging.
S/MIME adds cryptographic message formats for functions such as digital signatures and encryption. Their protection depends on certificates, keys, and the supported workflow. Ordinary MIME formatting alone does not provide these protections. See the S/MIME message specification.
Diagnose the mismatch
- Inspect the specific response or attachment, including its actual body.
- Compare its declared type with its content and intended use.
- For a website you operate, correct the route or server's type mapping as appropriate, then request the resource again.
- For an unexpected attachment, confirm the sender and purpose before opening it. A reassuring extension or media type is not evidence of safe content.
Browser decisions can also depend on context, content inspection, and the X-Content-Type-Options: nosniff response header. The MIME Sniffing Standard describes browser classification behavior. Use accurate media types and inspect the browser's actual error rather than assuming every download or display issue has the same cause.