Original post address: http://ons.javaeye.com/blog/368841
Entry description
[Edit this section
]
Multi-purpose Internet
Message extension (MIME, Multipurpose Internet Mail Extensions) is an internet standard that extends email
Standard to support non-ASCII
Character, binary
Email messages in multiple formats, such as attachments. This standard is defined in; RFC
2045, RFC 2046, RFC 2047, RFC 2048, and RFC 2049. RFC 822
2822. It is stipulated that the email standard does not allow the use of characters other than the 7-bit ASCII character set in mail messages. For this reason, non-English message and binary files, images, sounds, and other non-text Cancellation
Messages cannot be transmitted in emails. Mime specifies a symbolic method used to represent a variety of data types. In addition
HTTP
The mime framework is also used in the Protocol.
Mime usage
[Edit this section
] Multi-purpose Internet Mail Extension protocol (MIME) describes how to arrange message formats to make messages in different mail systems
. The MIME format is flexible, allowing emails to contain any type of files. MIME messages can contain specific data of text, images, sounds, videos, and other applications. Specifically, mime allows emails to include:
A single message can contain multiple objects;
A text document does not limit the length of a line or full text;
Transmission ASCII
Other character sets, allow messages in non-English languages;
Multi-font messages;
Binary
Or a specific application file;
Images, sounds, videos, and multimedia
Message.
The mime composite message directory header has a boundary mark. This boundary mark must not appear in other positions of the message, but only between departments and the beginning and end of the message body.
The secure MIME Version S/MIME (secure/Multipurpose Internet Mail Extensions) is designed to support mail encryption. Based on the MIME standard, S/MIME provides the following encryption security services for electronic message applications: authentication, integrity protection, authentication, and data confidentiality.
Traditional Mail User proxy (Mua
) You can use S/MIME to encrypt and decrypt the sent and received emails. However, S/MIME is not limited to the use of mail, it can also be applied to any mechanisms that can transmit MIME data, such as HTTP. Similarly, S/MIME uses mime's object-oriented features to allow secure message exchange in a hybrid transmission system.
In addition, S/MIME can also be applied to the automatic message transfer proxy, which uses encryption security services that do not require any operation, such as software
File signature and fax encryption sent to the Internet.
Protocol Structure
[Edit this section
] The information of a common text mail contains a header (:
From: Subject: and so on) and a part (hello
Mr .., and so on ). It is not surprising that a message header is contained in a mime-compliant message. Each part of the message is called a mime segment, and each segment is prefixed with a special header. Mime mail is only a base
An extension of RFC 822 mail. However, it has its own RFC specification set.
Based on the position in the package, the MIME header is generally divided into the mime information header and the mime field header. (TRANSLATOR: the MIME header refers to the entire mail header, while the MIME header is only the header of each mime segment .)
Mime information headers include:
Mime-version: This header provides the MIME Version Number used. This value is 1.0.
Content-Type: it defines the data type so that the data can be processed properly. Valid type
Include text, image, audio, video, applications, multipart, and message. Note that any binary attachment should be called.
Apply/octet-stream. Some examples of this header are: image/jpg, Application
/Mswork, multipart/mixed, which is only a small part.
Content-transfer-encoding: This is the most important one in all headers, because it describes the encoding method for the data, customer/Mua
It will be used to decode the attachment. For each attachment, you can use the encoding in 7bit, 8bit, binary, quoted-printable, base64, and custom.
Method. 7-bit encoding is a common encoding method used in the us ascii character set, that is, to keep it as it is. 8-bit and binary encoding are generally not used. Standard text that is readable to humans, if transmitted through a gateway that has an impact on the format
You can use quoted printable. Base64 is a common method. When you need to decide which encoding method to use, it provides a free-of-charge option. It is usually used in binary
Non-text data. Note that any non-7-bit data must be encoded in a mode so that it can pass the Internet
Email Gateway!
Content-ID: This header is useful if Content-Type is message/external-body or multipart/alternative. It exceeds this article
.
Content-Description: This is an optional Header. It is a free text description of any information segment. The description must use us-ASCII.
.
Content-Disposition: a pilot header used to provide a prompt to the customer Program/Mua to determine whether to display the attachment within the row or as a separate attachment.
Mime field header (the header that appears in the actual mime attachment part), except the mime-version header, can have any of the above header fields. If a MIME header is part of the information block,
It will act on the entire information body. For example, if content-transfer-encoding is displayed in the Information header, it applies to the entire information body, but if it displays
In a mime segment, it can only be used in that segment.
Note: It can automatically decrypt the received emails.
Mime Type
[Edit this section
] The earliest HTTP
There is no additional data type information in the protocol, and all transmitted data is interpreted as hypertext by the client program
To support multimedia data types, the HTTP protocol uses the MIME data type information appended to the document to identify the data type.
Mime indicates multi-object Internet
Email extension, designed initially to send emails
Additional multimedia
Data so that the email client program can process the data according to its type. However, when it is supported by the HTTP protocol, its meaning becomes more significant. It makes HTTP transmitted not only plain text, but also rich and colorful.
Each MIME type consists of two parts. The front part is a large data type, such as audio, image, and so on. The latter part defines a specific type.
Common MIME types
Hypertext markup language text .html, .html text/html
Common text. TXT text/plain
RTF
Text. rtf application/RTF
GIF
Image. GIF image/GIF
JPEG
Image .ipeg,.jpg image/JPEG
AU audio file. Au audio/basic
MIDI
Music files mid,. MIDI audio/Midi, audio/X-Midi
RealAudio
Music file. Ra,. Ram audio/X-PN-RealAudio
MPEG
File. mpg,. MPEG Video/MPEG
Avi
File. AVI Video/X-msvideo
Gzip
File. GZ application/X-Gzip
Tar
File. Tar application/X-Tar
Iana is a specialized organization in the Internet.
Come
Confirm the standard MIME type, but the Internet is growing too fast, many applications cannot wait for IANA to confirm that they are using the standard MIME type. Therefore, they use
Method IDs starting with X-have not yet become the standard, such as X-gzip and X-tar. In fact, these types are widely used and have become the de facto standard. As long as the client and server
This MIME type is recognized together, and even if it is not a standard type, it does not matter, the customer program can use specific processing methods to process data according to the MIME type. Web
Servers and browsers (including operating systems
), The standard and common MIME types are set by default. Only for uncommon MIME types, you must set both the server and the client browser.
For identification.
Because the MIME type is related to the document suffix, the server uses the document suffix to distinguish the MIME types of different files. The server must define the correspondence between the document suffix and the MIME type.
When the client program receives data from the server, it only accepts data streams from the server and does not know the document name. Therefore, the server must use additional information to tell the client program
The MIME type of the data. Before the server sends real data, it must first send the MIME type information of the Flag data. This information is defined using the Content-Type keyword, for example, for HTML
The server will first send the following two lines of mime identification information, which is not part of a real data file.
Content-Type: text/html
Note that the second act is a blank line, which is required to separate the mime information from the real data content.
Mime utilizes the fact that RFC 822 imposes a limit on the content of the message body: the only restriction is that it can only use simple ASCII
Text. Therefore, mime information is transmitted from the normal internet
Text mail composition, text mail
It has some special information headers that comply with RFC 822 and formatted Information bodies (attachments expressed by ASCII subsets ). These MIME headers provide a special way to indicate attachments in the mail.
Browser Applications
[Edit this section
] Mime was first used in email in 1992
System, but later applied to the browser
. The server sends the multimedia
The data type tells the browser, and the notification means to indicate the MIME type of the multimedia data, so that the browser can know which information is received by MP3
Which are shockwave files?
Files. The server puts the mime token into the transmitted data to tell the browser which plug-in is used to read the relevant file.
After the browser receives the file, it will go to the plug-in system to find out which plug-in can identify and read the received file. If the browser does not know which plug-in system to call, it may tell the user that a plug-in is missing, or directly select an existing plug-in to try to read the received file, which may cause the system
. The absence of mime identifiers in the transmitted information may make it difficult to estimate the situation, because some computer systems may not have any faults, but some computers may crash.
To check whether a server correctly sets the MIME type, follow these steps:
1. In Netscape
Open Server webpage in browser
2. Go to the & #34; view & #34; menu and select & #34; Page info & #34;
3. In the pop-up window, click & amp; #34; embed & amp; #34; in the upper framework;
4. Check whether the MIME type is & #34; application/X-Director & #34; in the lower-layer framework;
Or & #34; application/X-Shockwave-flash & #34;. If the preceding information is used, the server has been correctly set
MIME type. If the MIME type lists text content, eight-bit data, or other forms, the server's MIME type is not set correctly.
If the server does not correctly indicate the type of data it sends, the server administrator should correctly add relevant information. The specific operation method is very simple and quick.
Microsoft
Windows
The browser in the system uses ActiveX
Control
Instead of the Netscape plug-in, such browsers do not rely on mime encoding as other browsers do. & Amp; #34; object & amp; #34; tag
The & #34; CLSID & #34; Attribute accurately identifies the program to be called to read the received file, so the browser does not need
Select a reader like the & #34; embed & #34; tag. Because of this, you will often encounter mime problems when using a browser with plug-ins.
ActiveX controls are rarely used in browsers.
Due to the difference in the above working methods, I wonder if you have found that you are playing wav In the Netscape Browser.
The browser will call liveconnect
Plug-in for playback, while other browsers generally use the common QuickTime
This is because the Netscape Browser needs to read the mime identifier to determine which program to call.
Come
The server sets the livconnect plug-in to play wav files in the Netscape browser. Therefore, the Netscape Browser receives wav files.
But other browsers do not use this method, so they all use the default player for playing wav files. Of course flash
This problem does not exist in movie files, because only Flash players can correctly read files in this format.
When sending the output to a browser, the browser must start an appropriate application.
To process this output document. This can be done through multiple types of mime (multi-function Internet Mail Extension protocol. In HTTP, the MIME type is defined in the Content-Type header.
For example, if you want to transfer a Microsoft Excel file
File to the client. The MIME type is "application/vnd. MS-excel ". In most cases, this file is then transmitted to execl for processing (assuming we set execl to an application that handles special MIME types ). In ASP
To set the MIME type, use the contenttype attribute of the response object.
Email application
[Edit this section
] A mime message can be composed of multiple different types of MIME messages. A mime message represents a basic mime resource in the message or a combination of several basic MIME messages. The data format and RFC of each mime message
822
The data format is similar to that of the header and body, which are called the mime message header and the mime message body. They are separated by blank lines. The mime message body contains the specific content of the resource.
The header contains the description of the resource. Multiple MIME messages of the same level must form a mime message combination, which serves as the mime Message Body of the formed mime combination message.
The message headers of mime message combinations must describe the combination types and identifiers of multiple MIME messages. A mime message can be combined
Other MIME messages form a larger combination of MIME messages, which forms a multi-layer nested combination. A mime message is a top-level combination formed by this combination.
Mime message combination.