
MIME is a protocol that helps the internet understand what type of file it's dealing with. It's like a label on a package that says what's inside.
MIME stands for Multipurpose Internet Mail Extensions, and it was first introduced in 1992. This was a big deal because it allowed email clients to send and receive files in different formats.
The main job of MIME is to identify the type of file being sent or received, so the receiving end knows how to handle it. For example, if someone sends you a picture, MIME will tell the email client that it's a JPEG file.
MIME also helps with content transfer encoding, which is a fancy way of saying it helps with file compression. This is useful when sending large files over the internet, as it can save time and bandwidth.
For more insights, see: Media Type
MIME Structure
A MIME email consists of several parts, each with its own specific purpose.
The MIME-Version field specifies the version of MIME being used. This is usually version 1.0.
The Content-Type field describes the type of the content, such as text, image, or audio. For example, text/plain or image/jpeg.
The Content-Transfer-Encoding field specifies how the content is encoded for transmission, like base64 or quoted-printable.
The Content-Disposition field defines whether the content is inline or as an attachment.
Here's a quick rundown of the MIME structure:
- MIME-Version: specifies the version of MIME
- Content-Type: describes the type of the content
- Content-Transfer-Encoding: specifies how the content is encoded
- Content-Disposition: defines whether the content is inline or as an attachment
MIME Types
MIME types are used to identify the type of data in a file, and they're crucial for web development. The IANA (Internet Assigned Numbers Authority) maintains a registry of MIME types, which includes categories like application/octet-stream for generic binary data, text/plain for plain text, and image/jpeg for JPEG images.
You should use the correct MIME type for a file to ensure it's handled properly by web browsers. For example, if you're serving a JavaScript file, use text/javascript to guarantee it works across all browsers. Using legacy JavaScript MIME types like application/javascriptDeprecated can lead to compatibility issues.
Recommended read: Mime Types
Here are some common MIME types you should know:
Setting the correct MIME type can also have security implications. For instance, if you serve a file with an unrecognized MIME type, it may be blocked by browsers to prevent malicious actions.
A unique perspective: Webp Mime Type
Discrete Types
Discrete types are a crucial part of MIME types, and they're used to categorize binary data that doesn't fit into other types. This includes data that will be executed or interpreted in some way, or binary data that requires a specific application or category of application to use.
For example, generic binary data, or binary data whose true type is unknown, is classified as application/octet-stream. Other common examples include application/pdf, application/pkcs8, and application/zip.
Here are some common discrete types:
Discrete types can also include audio or music data, such as audio/mpeg or audio/vorbis. These types are used to specify the format of the audio data.
Broaden your view: Picture Mime Types
Application/Json
Application/Json is a widely used MIME type for transmitting data in web applications. It's based on JavaScript object syntax and represents structured data in a text-based format.
JSON is commonly used for data exchange between web servers and clients, making it a crucial part of web development. This format is easy to read and write, which is why it's a popular choice among developers.
JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax. It's often used in web applications to send and receive data between the server and client.
The simplicity of JSON makes it a great choice for many applications, from small web projects to large-scale enterprise systems. Its text-based format also makes it easy to debug and troubleshoot issues.
Consider reading: MIME Object Security Services
Related
A multipart/related is used to indicate that each message part is a component of an aggregate whole. This means it's for compound objects consisting of several inter-related components – proper display cannot be achieved by individually displaying the constituent parts.
The message consists of a root part (by default, the first) which reference other parts inline, which may in turn reference other parts. Message parts are commonly referenced by Content-ID.
The syntax of a reference is unspecified and is instead dictated by the encoding or protocol used in the part. This allows for flexibility in how the parts are referenced.
One common usage of this subtype is to send a web page complete with images in a single message. The root part would contain the HTML document, and use image tags to reference images stored in the latter parts.
Legacy MIME
Legacy MIME types are a thing of the past, but it's still good to know about them. They're a bit of a mess, but we'll break it down for you.
There are several legacy MIME types that are no longer recommended for use, but are still supported by some browsers for historical reasons. This includes application/javascriptDeprecated, application/ecmascriptDeprecated, and several others that are listed below.
Here are the legacy JavaScript MIME types that you should avoid using:
- application/javascriptDeprecated
- application/ecmascriptDeprecated
- application/x-ecmascriptNon-standard
- application/x-javascriptNon-standard
- text/ecmascriptDeprecated
- text/javascript1.0Non-standard
- text/javascript1.1Non-standard
- text/javascript1.2Non-standard
- text/javascript1.3Non-standard
- text/javascript1.4Non-standard
- text/javascript1.5Non-standard
- text/jscriptNon-standard
- text/livescriptNon-standard
- text/x-ecmascriptNon-standard
- text/x-javascriptNon-standard
The only MIME type you should use is text/javascript, as it's the only one guaranteed to work now and into the future.
Legacy JavaScript Types
The MIME Sniffing Standard allows for a variety of legacy JavaScript MIME types, which are no longer recommended for use.
These types include application/javascript, application/ecmascript, application/x-ecmascript, application/x-javascript, text/ecmascript, text/javascript1.0, text/javascript1.1, text/javascript1.2, text/javascript1.3, text/javascript1.4, text/javascript1.5, text/jscript, text/livescript, text/x-ecmascript, and text/x-javascript.
You should only use text/javascript, as it's the only MIME type guaranteed to work now and into the future.
Here is a list of the legacy JavaScript MIME types:
- application/javascript
- application/ecmascript
- application/x-ecmascript
- application/x-javascript
- text/ecmascript
- text/javascript1.0
- text/javascript1.1
- text/javascript1.2
- text/javascript1.3
- text/javascript1.4
- text/javascript1.5
- text/jscript
- text/livescript
- text/x-ecmascript
- text/x-javascript
Alternative
MIME types can be a bit of a mess, especially when it comes to alternatives. The multipart/alternative subtype is used to indicate that each part is an "alternative" version of the same content, each in a different format.
This structure is significant, with the order of the parts mattering. According to RFC1341, user agents should place the body parts in increasing order of preference, with the preferred format last.
In practice, this means that the plain text version (if present) is usually placed first, making life easier for users of clients that don't understand multipart messages. Most commonly, multipart/alternative is used for email with two parts: one plain text and one HTML.
The standard doesn't require each part to represent the same content, but it's intended that they should. Some anti-spam filters used to only examine the text/plain part, but spammers eventually found ways to exploit this, creating messages with innocuous-looking text/plain parts and advertising in the text/html part.
Here's a breakdown of the multipart/alternative structure:
- Plain text version (text/plain) is usually placed first.
- HTML version (text/html) is usually placed last.
- Order of the parts is significant, with the preferred format last.
Signed
A multipart/signed message is used to attach a digital signature to a message.
This type of message has exactly two body parts: a body part and a signature part.
The whole of the body part, including mime fields, is used to create the signature part.
Many signature types are possible, like "application/pgp-signature" (RFC 3156) and "application/pkcs7-signature" (S/MIME).
Advantages
Legacy MIME has several advantages that make it a reliable choice for sending and receiving emails. One of the biggest advantages is its ability to support multiple data types, including text, audio, video, images, and application files.
MIME enables the transfer of diverse data formats, making it possible to send a wide range of files via email. This is especially useful for sending files like RAR-compressed files, which can contain multiple resources of different types.

A specific MIME type for RAR-compressed files is application/x-rar-compressed, which allows users to set the correct default action for such resources. This is especially important for security reasons, as most browsers do not allow setting a custom default action for unrecognized resources.
The correct MIME type is crucial for playing audio and video resources in video or audio elements. If the MIME type is incorrect, the resources will not be played.
MIME also supports multiple attachments of different types in the same email, making it a convenient choice for sending files of various formats. This is a significant advantage over SMTP, which has limitations on message length and attachment types.
MIME defines four subtypes for multipart messages, including "multipart/alternative", which lets systems choose the best representation of the message: plain text or HTML. This feature is especially useful for sending emails with multiple formats, such as plain text and HTML versions.
Here are some examples of MIME types for different file types:
These are just a few examples of the many advantages of Legacy MIME. Its ability to support multiple data types, send diverse files, and handle long messages make it a reliable choice for sending and receiving emails.
Drawbacks of SMTP
SMTP, the standard protocol for delivering messages via email, has some significant drawbacks. It emerged in 1981 and was originally designed to support only 7-bit ASCII text communications, which were both unauthenticated and unencrypted.
This limitation means that SMTP can't handle binary files or characters in non-English languages that use different writing systems, accented letters, etc. In fact, the system can only deal with 94 printable characters in ASCII.
SMTP also doesn't accommodate sending video or audio data, which can be a major issue for multimedia communications.
The default design of every SMTP server was an open mail relay that lets anyone send emails through it, not just those from or to known users. This made SMTP communications vulnerable to email spoofing, spamming, worms, and man-in-the-middle (MitM) attacks.
Here are some of the key limitations of SMTP:
- Only supports 7-bit ASCII text communications
- Can't handle binary files or non-ASCII characters
- Can't send video or audio data
- Default design is an open mail relay, making it vulnerable to attacks
Content Settings
Content Settings are crucial for ensuring your files are handled correctly by browsers and servers.
Some server configurations may use the associated MIME type to perform optimizations, such as file concatenation, compression, or caching.
Setting the correct MIME type for RAR-compressed files is ideal, but often impossible since .RAR files can hold several resources of different types.
Configuring the server to send application/x-rar-compressed can help.
Only resources with the correct MIME Type will be played in video or audio elements.
Be sure to specify the correct media type for audio and video.
A specific type like application/vnd.mspowerpoint lets users open such files automatically in the presentation software of their choice.
Header Fields
MIME header fields are made up of multiple subparts. A MIME header contains these subparts.
Each subpart has its own specific purpose, such as including multiple types of content in a single message.
Header Fields
A MIME header contains multiple subparts, including the ones mentioned in Example 1.
These subparts are essential for organizing and structuring the information within a MIME header.
A MIME header contains multiple subparts, including MIME header fields.
MIME header fields are a crucial part of these subparts, providing specific information about the email or data being sent.
For example, we know from Example 1 that a MIME header contains multiple subparts, including MIME header fields.
Report
The report message type is a game-changer for mail servers. It's defined in RFC 6522.
multipart/report is a specific type of report that contains data formatted for a mail server to read. This data is split into two parts: a text/plain section and a message/delivery-status section.
The text/plain section is easily readable, while the message/delivery-status section contains the data formatted for the mail server to read. This makes it a crucial part of the report message type.
multipart/report is designed to provide detailed information to the mail server, making it an essential tool for email delivery and management.
X-Mixed-Replace
X-Mixed-Replace was developed by Netscape as part of a technology to emulate server push and streaming over HTTP.
It's still supported by Mozilla, Firefox, Safari, and Opera.
This content type is commonly used in IP cameras as the MIME type for MJPEG streams.
Clients should process individual parts as soon as they arrive, rather than waiting for the whole message to finish.
It was supported by Chrome for main resources until 2013.
Multipart Messages
A multipart message is a type of MIME message that contains multiple parts, each with its own content and headers. This allows for complex documents to be broken down into smaller, more manageable pieces.
The boundary is a crucial element in a multipart message, and it's used to separate the different parts of the message. This boundary is specified in the Content-Type header field, and it must not occur in any of the parts. Typically, a long random string is used as the boundary to avoid conflicts with the body text.
The boundary is placed at the beginning and end of the message body, as well as between each part. This is done to clearly separate the different components of the message.
Before the first boundary, there is an area that is ignored by MIME-compliant clients. This area is often used to include a message for users of old, non-MIME clients.
To ensure that the boundary doesn't clash with the body text, the sending mail client typically chooses a long random string. The last boundary must have two hyphens at the end.
Here are some key points to keep in mind when working with multipart messages:
- The boundary is specified in the Content-Type header field.
- The boundary must not occur in any of the parts.
- The boundary is placed at the beginning and end of the message body, as well as between each part.
- The last boundary must have two hyphens at the end.
Multipart/Form-Data
Multipart/form-data is a type of MIME type that allows sending multiple files as part of the same transaction. It's commonly used for submitting files with HTTP.
This type of MIME type can represent multiple, separate files that are all part of the same transaction. It's especially useful in email scenarios.
Multipart/form-data is used in the POST method of HTML Forms, where it's used to send file uploads. The message is transmitted to the browser, which will likely show a "Save As" window if it doesn't know how to display the document.
Each part of the multipart/form-data type has its own HTTP headers, Content-Disposition, and Content-Type. This allows for different types of files to be sent as part of the same transaction.
The boundary is a string starting with a double dash --, which delimits each part of the multipart/form-data type. This makes it easy to identify each part of the message.
Multipart/form-data is specified in RFC 7578, which superseded RFC 2388. This is the standard for this type of MIME type.
Image and Video
Image and Video files are handled by MIME types that specify their format. These formats are essential for web pages to display images correctly.
The most commonly used image types include image/apng: Animated Portable Network Graphics (APNG)image/avif : AV1 Image File Format (AVIF)image/gif: Graphics Interchange Format (GIF)image/jpeg: Joint Photographic Expert Group image (JPEG)image/png: Portable Network Graphics (PNG)image/svg+xml: Scalable Vector Graphics (SVG)image/webp: Web Picture format (WEBP) for displaying different types of images.
For instance, image/jpeg is used for Joint Photographic Expert Group images.
Image
Image files are a crucial part of the web, and understanding the different types is essential for a smooth user experience.
You might be surprised to know that there are many image file types, but some are more commonly used than others. The most widely used image types are image/jpeg, image/png, image/gif, and image/svg+xml.
Let's take a closer look at some of the most popular image file types. Here are a few examples:
- image/jpeg: This is one of the most widely used image file types, and it's great for photos and other images with a lot of detail.
- image/png: This file type is ideal for images with transparent backgrounds, like logos and graphics.
- image/gif: This file type is perfect for animations and images with a lot of color.
- image/svg+xml: This file type is great for scalable vector graphics, like icons and logos.
Some other image file types worth mentioning include image/apng, image/avif, and image/webp. Each of these file types has its own unique features and uses, but they're not as widely supported as the ones mentioned above.
Working and Characteristics
MIME allows email messages to contain characters from character sets beyond ASCII, such as UTF-8.
It enables emails to include multimedia content like images, video, and audio files as attachments. These attachments can be encoded into ASCII text format using base64 or other encoding schemes to ensure they can be sent over a text-based protocol.
MIME introduces special header fields that define how the content should be interpreted, such as Content-Type and Content-Disposition.
The Content-Type header tells the receiving email client what kind of data is being sent, like text, image, or audio.
MIME can structure an email as multipart with a boundary separator to distinguish between different parts, like a mix of text and attachments.
Here are the key MIME header fields and their functions:
- MIME-Version: Defines the version of the MIME protocol, which must be 1.0.
- Content-Type: Specifies the type of data in the message body.
- Content-Transfer-Encoding: Indicates the encoding method used to transmit the message safely.
- Content-ID: Provides a unique identifier for each MIME part.
- Content-Description: Describes the nature of the content to understand what's included.
MIME is used to convert non-ASCII data to 7-bit NVT ASCII format for transmission, and then convert it back to the original non-ASCII code for the recipient to read.
Origins and How it Works
MIME was first proposed in 1991 by Nathaniel Borenstein to extend SMTP and allow for the recognition and handling of various data types, not just Latin-based ASCII text.
Borenstein's proposal aimed to address the shortcomings of email and SMTP, and it led to the addition of new file types to the "mail" protocol.
New MIME data types are registered with the Internet Assigned Numbers Authority (IANA).

The IETF's RFC 6838 defines the procedures to notify and register media types for use in MIME.
MIME is not limited to textual data and is also important for other communication protocols, even though it was originally designed for email and SMTP.
MIME's flexibility allows it to support a wide range of data types, making it a crucial component of modern email systems.
MIME works by transforming non-ASCII data into 7-bit NVT data, which can be transmitted over SMTP.
At the recipient's end, the message is transferred back to the original data, allowing users to view its contents, regardless of whether it contains text, audio, video, or other types of data.
The MIME header is inserted at the beginning of an email transmission by servers and is used by clients to select an appropriate player application for the data type indicated by the header.
Here's a summary of the MIME header key fields and their functions:
Origins of

The origins of MIME date back to 1991, when Nathaniel Borenstein proposed extending SMTP to handle non-ASCII text and binary files.
Nathaniel Borenstein was a technical staff member at Bellcore at the time, and he wanted to address the shortcomings of email and SMTP.
The Internet Engineering Task Force (IETF) took Borenstein's proposal seriously and added new file types to "mail" as a supported Internet Protocol file type.
MIME is not just for email, it's also used in other communication protocols, and it's not limited to textual data.
New MIME data types are registered with the Internet Assigned Numbers Authority (IANA), which is the organization responsible for managing the internet's domain name system.
The IETF's RFC 6838 defines the procedures for notifying and registering media types for use in MIME.
How it Works
MIME is a protocol that helps send and receive emails with non-ASCII formats.
The MIME protocol converts non-ASCII data into 7-bit NVT ASCII format, which can be transferred through email systems. This allows users to send and receive emails with various types of data, including text, images, and audio.

MIME introduces the Content-Type header, which tells the receiving email client what kind of data is being sent. For example, text, image, or audio.
If a message contains multiple parts, such as a mix of text and attachments, MIME can structure the email as multipart with a boundary separator to distinguish between different parts.
Here are the key fields in the MIME header and their functions:
Emails with MIME formatting can be transmitted via standard protocols like SMTP, POP, or IMAP. The MIME header is inserted at the beginning of an email transmission by servers, and clients use it to select an appropriate player application for the data type indicated by the header.
Content Encoding
Content Encoding is a crucial aspect of MIME, allowing for the representation of binary data in formats other than ASCII text. The Content-Transfer-Encoding header field provides two-sided significance, indicating whether a binary-to-text encoding scheme has been used on top of the original encoding specified in the Content-Type header.
If a binary-to-text encoding method has been used, the header field states which one; if not, it provides a descriptive label for the format of content, with respect to the presence of 8-bit or binary content. The values '7bit', '8bit', and 'binary' mean that no binary-to-text encoding on top of the original encoding was used, and the header field is actually redundant for the email client to decode the message body.
The Content-Transfer-Encoding header field can be used with normal SMTP, as well as with SMTP servers that support the 8BITMIME SMTP extension (RFC 6152) and the BINARYMIME SMTP extension (RFC 3030). However, there is no encoding defined which is explicitly designed for sending arbitrary binary data through SMTP transports with the 8BITMIME extension.
Here are the possible values for the Content-Transfer-Encoding header field, which are not case sensitive:
- '7bit'
- '8bit'
- 'binary'
- 'quoted-printable'
- 'base64'
Content Transfer Encoding
Content Transfer Encoding is a crucial aspect of email communication. It's used to indicate whether a binary-to-text encoding scheme has been applied to the original encoding specified in the Content-Type header.
The Content-Transfer-Encoding header field has two main purposes: to indicate if a binary-to-text encoding method has been used and to provide a descriptive label for the format of the content. If a binary-to-text encoding method has been used, it states which one. If not, it provides a descriptive label for the format of the content.
Values like '7bit', '8bit', and 'binary' mean that no binary-to-text encoding on top of the original encoding was used. These values are not case sensitive and are suitable for use with normal SMTP. However, they may still be useful as an indicator of what type of object is being sent.
The Content-Transfer-Encoding header field is also used to indicate if base64 or quoted-printable encoding has been used. This is necessary because these encodings can be used to represent binary data in a text format.
Here are the common values used in the Content-Transfer-Encoding header field, along with their meanings:
- 7bit: No binary-to-text encoding was used.
- 8bit: No binary-to-text encoding was used, but the content may contain 8-bit characters.
- binary: No binary-to-text encoding was used, and the content is binary data.
- quoted-printable: A binary-to-text encoding scheme was used, and the content is encoded in a quoted-printable format.
- base64: A binary-to-text encoding scheme was used, and the content is encoded in a base64 format.
It's worth noting that while base64 and quoted-printable encodings can be used to represent binary data in a text format, they can be inefficient and may not be suitable for large amounts of data.
Encrypted
Encrypted messages have a control part that contains information needed to decrypt the message. This control part is usually identified by a specific content type.
The most common types are "application/pgp-encrypted" and "application/pkcs7-mime". The first one is defined in RFC 3156, which is a standard for secure communication.
These types are used to implement different encryption methods, such as PGP and S/MIME. The MIME type defined in RFC 1847 is also used for encrypted messages.
Encrypted messages typically have two parts: a control part and an encrypted part. The control part contains the information needed to decrypt the message.
The encrypted part is usually identified by the MIME type "application/octet-stream". This type is often used for binary data, such as encrypted files.
Byte Range and Message
The multipart/byterange is used to represent noncontiguous byte ranges of a single message. It's defined in RFC 2616.
This type is crucial for HTTP when a server returns multiple byte ranges.
There are many types of messages, including bhttp, CPIM, and disposition-notification. These types are defined in various RFCs, such as [RFC9292], [RFC3862], and [RFC8098].
Here are some examples of message types:
The multipart/byteranges MIME type is used to send partial responses to the browser. This is indicated by the 206 Partial Content status code.
Respond and Version
The MIME-Version header field is a crucial part of MIME-formatted messages, indicating that the message is MIME-formatted.
Its value is typically "1.0", a version number that was introduced to permit changes to the MIME protocol in subsequent versions.
However, the specification for handling future versions was inadequate, leading to inconsistent implementations.
According to MIME co-creator Nathaniel Borenstein, this shortcoming made it difficult for the Internet to define a new version, such as "2.0" or "1.1".
Respond
Respond is a crucial part of the process, and it's essential to understand the different types of responses that can be given.
A response can be a simple "yes" or "no" answer, but it can also be a detailed explanation or clarification.
The key is to provide a response that is relevant to the original question or request.
In some cases, a response may require a version of the original message to be sent back to the person who made the request.
This is known as a "versioned response", and it's often used in situations where a change or update is needed.
A versioned response can be sent back to the person who made the request, or it can be stored in a database for future reference.
In either case, the versioned response is a way to keep track of changes and updates to the original message.
Responding in a timely manner is also important, as it shows that you value the person's time and are committed to providing a solution.
Version
The MIME-Version header field indicates the message is MIME-formatted, and its value is typically "1.0".

This field was introduced to permit changes to the MIME protocol in subsequent versions, but it has some shortcomings.
The MIME co-creator Nathaniel Borenstein admitted that the specification did not adequately address how to handle a future MIME version, leading to inconsistent implementations.
This makes it difficult for the Internet to define a new version, such as 2.0 or 1.1.
The value of the MIME-Version field is typically just "1.0", without any additional information.
Featured Images: pexels.com

