10

What is the content type for MHT files?

Luke Quinane
  • 15,732
  • 13
  • 64
  • 87
Krishna Kumar
  • 4,744
  • 13
  • 43
  • 46
  • 2
    This resource is quite helpful. [Webmaster-Toolkit: Mime Types](http://www.webmaster-toolkit.com/mime-types.shtml) –  Apr 02 '12 at 16:29

5 Answers5

9

Microsoft, who co-authored the spec for MHT, seem to think that it should be 'message/rfc822' on this support page.

No specific MIME type seems to be given in the spec though: RFC2557: MIME Encapsulation of Aggregate Documents, such as HTML (MHTML)

Luke Quinane
  • 15,732
  • 13
  • 64
  • 87
  • See also here: https://www.w3.org/Protocols/rfc1341/7_3_Message.html: *A Content-Type of "message/rfc822" indicates that the body contains an encapsulated message, with the syntax of an RFC 822 message.* – Wilt Sep 23 '20 at 16:00
7

I know this is old, but I thought it should be clarified and explained in more detail...

@Guy Starbuck wrote:

message/rfc822

RFC 822 - STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES

The problem with this answer is that MHTML files are not defined by RFC822.

The correct content-type for MHTML files (.mht, .mhtml) is multipart/related.

As stated above, RFC822 defines the format for internet text messages. The content-type message/rfc822 is used for text attachments within email messages [1][2].

Most of us have probably received a reply to an email where, instead of being quoted inline, the original message is included as an attachment. That attachment has a content-type of message/rfc822. In such emails, the content-types break down as follows:

  • multipart/mixed = entire message
  • text/plain = text of reply email
  • message/rfc822 = original email as attachment

On the other hand, as noted by @feeela, MHTML files are defined in RFC2557. MHTML files are comprised of many different parts, each of which can have a different content-type. However, RFC2557 defines the content-type of the entire file as multipart/related.

[1] RFC1341: MIME (Multipurpose Internet Mail Extensions)
[2] The message Content-Type

geo
  • 241
  • 5
  • 5
  • At least in my testing, if you use "multipart/related", IE prompts you to download the file. If you use "message/rfc822", IE opens it inline. – Josh Mouch Sep 29 '15 at 22:26
  • `MHT` files are structured in exactly the same way `RFC822`(and following) define the `MAIL` message. According to https://tools.ietf.org/html/rfc2046 the `message/rfc822` defines a _composite_ object, which represents a `MAIL` message, where body may be of any type, and header specify, how it should be interpreted. This said, `message/rfc822` is a closest correct answer, even if it is not explicitly specified. Another type I've seen used for MHTML files is application/mime, but it will cause filesto be downloaded in most cases. – AnrDaemon May 05 '17 at 13:53
  • `multipart/mixed` is a content-type for message BODY only. – AnrDaemon May 05 '17 at 13:57
4

message/rfc822

RFC 822 - STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES

Here is a hyperlink: message/rfc822

Guy Starbuck
  • 20,727
  • 6
  • 51
  • 63
2

"MIME Encapsulation of Aggregate Documents, such as HTML" (MHTML or MHT) is an IETF standard proposed in 1999 in the RFC 2557.

Its MIME type is multipart/related and the extension is .mht.

See also:

feeela
  • 26,359
  • 6
  • 56
  • 68
  • "multipart/related" would be a MIME type for MHT content. But not for MHT itself. – AnrDaemon May 05 '17 at 13:45
  • @AnrDaemon MIME types always designate contents. It not primarily about the file ending. And: “The content of an MHTML file is encoded as if it were an HTML e-mail message, using the MIME type multipart/related.” Thus this should be correct. – feeela May 08 '17 at 14:36
  • You're missing the point. MHT has its own MIME header which is a part of the "document body" when you transfer it. – AnrDaemon May 11 '17 at 18:41
-4

application/octet-stream

You can stream the contents of a .eml file to a browser with this content type and .mht as the extension, and the email will be rendered similar to the way it is rendered in an email client.

Eric Z Beard
  • 35,488
  • 25
  • 97
  • 144