The Application Layer & HTTP

MIME

/ mime /

Original email could carry only plain English text — strictly 7-bit ASCII letters. No images, no PDFs, no Chinese characters, no song attached to a message. MIME is the clever wrapper that lets all of that travel through a system built only for text. It works by encoding any kind of binary data into safe text characters and labelling what it really is, so a photo can ride inside a plain-text email and be reassembled into a photo at the other end.

MIME does two jobs. First, it labels content with a media type (also called a MIME type), written as type/subtype: text/plain, text/html, image/jpeg, application/pdf, application/json. This label tells the receiver how to interpret the bytes — show it as text, render it as a webpage, open it as a PDF. Second, for data that is not plain text, MIME encodes it into ASCII, most often with Base64, which represents arbitrary bytes using only safe letters, digits, and a couple of symbols. A single email can also be multipart — a multipart/mixed message bundles, say, a text/plain note plus an image/jpeg attachment, each part with its own type header, separated by a boundary marker.

MIME's reach goes far beyond email. The exact same media-type system labels content on the web: the HTTP "Content-Type: text/html" or "Content-Type: image/png" header is a MIME type, telling your browser whether the bytes are a page, a picture, or a download. So MIME quietly underpins both how an attachment survives an email system and how a browser knows what it just received. The honest cost is size: Base64 encoding inflates binary data by about a third, since it spends extra characters to stay text-safe — a deliberate trade of efficiency for compatibility with old text-only infrastructure.

You email a photo. Your mail app builds a multipart/mixed message: part one is text/plain ("Here's the picture!"), part two is image/jpeg encoded as Base64 (the photo turned into a long block of letters). The receiving app reads the type labels, decodes the Base64 back into the original bytes, and shows you both a note and an image.

MIME labels content (type/subtype) and encodes binary into text, so non-text survives text-only channels.

A MIME type is a declared label, not a verified fact — a server can claim text/plain for something that is really HTML. Browsers historically guessed ("MIME sniffing"), which caused security bugs, so today they are told to trust the declared type.

Also called
Multipurpose Internet Mail Extensionsmedia typecontent type多用途網際網路郵件延伸