当前位置:网站首页>[mime notes]

[mime notes]

2022-07-07 19:08:00 Full stack programmer webmaster

Hello everyone , I meet you again , I'm the king of the whole stack .

I am interested in some technical details of the Internet recently , I plan to take a series of notes .

=================

MIME note

1.

MIME The full name is ”Multipurpose Internet Mail Extensions”, The Chinese translation is ” Multi purpose Internet mail extension ”, It refers to a series of e-mail technical specifications , It mainly includes RFC 2045、RFC 2046、RFC 2047、RFC 4288、RFC 4289 and RFC 2077.

seeing the name of a thing one thinks of its function ,MIME It's an extension of traditional email , Now it has become the de facto standard for email .

2.

Traditional email is 1982 Set the technical specifications in , File is RFC 822.

An important feature of it , It stipulates that email can only be used ASCII character . This leads to three results :1) Non English characters cannot be used in email ;2) Binary files cannot be inserted into email ( Such as images );3) Email cannot have attachments .

This is actually unacceptable , So here we are 1992 year , Engineers decided to expand the technical specification of e-mail , Propose a series of supplementary specifications , This is it. MIME The origin of .

3.

Here is a traditional email .

From: “Tommy Lee” <[email protected]> To: “Jack Zhang” <[email protected]> Subject: Test Date: Wed, 17 May 2000 19:08:29 -0400 Message-ID: <[email protected]> Hello World.

As can be seen from the above , The address of the sender of this letter is [email protected], The address of the addressee is [email protected], The subject of the email is Test, The sending time is 2000 year 5 month 17 Japan , The content of the email is ”Hello World.”.

On the structure , The letter is divided into three parts : The first is the letter header , And then there's a blank line , Finally, the content of the letter . The recipient's client software will only display the last part , To view Quanxin , You have to use ” View the original message ” function .

4.

MIME Extensions to traditional email , It shows that it adds several sentences in the head of the letter , There are mainly three .

The first is :

MIME-Version: 1.0

This statement is necessary , and 1.0 The value of this version is unchanged , Even if MIME It has been upgraded several times .

With this sentence , The receiver knows that this letter is used MIME standard .

5.

The second sentence is :

Content-Type: text/plain; charset=”ISO-8859-1″

This line is extremely important , It indicates the type of information transmitted and the coding used .

Content-Type Indicate the type of information , The default value is ” text/plain”. It contains the main types (primary type) And the secondary type (subtype) Two parts , Use... Between the two ”/” Division . The main types are 9 Kind of , Namely application、audio、example、image、message、model、multipart、text、video.

There are many secondary types under each primary type , Common are :

text/plain: Pure text , File extension .txt text/html:HTML Text , File extension .htm and .html image/jpeg:jpeg Format picture , File extension .jpg image/gif:GIF Format picture , File extension .gif audio/x-wave:WAVE Format audio , File extension .wav audio/mpeg:MP3 Format audio , File extension .mp3 video/mpeg:MPEG Video format , File extension .mpg application/zip:PK-ZIP Format of compressed files , File extension .zip

The details of the Content-Type list , You can check here and here .

If the main type of information is ”text”, Then you must also specify the encoding type ”charset”, The default value is ASCII, Other possible values are ”ISO-8859-1″、”UTF-8″、”GB2312″ wait .

Whole Content-Type This business , Not only in email , Later, it was transplanted to HTTP Agreement , So now as long as it is spread online HTTP Information , All carry Content-Type head , To indicate the type of information .

6.

I've said that before , The traditional format of e-mail does not support non ASCII Coding and binary data . therefore MIME The third sentence is prescribed :

Content-transfer-encoding: base64

This statement indicates the way of encoding conversion .Content-transfer-encoding The value is 5 Kind of —-“7bit”、”8bit”、”binary”、”quoted-printable” and ”base64”—- among ”7bit” Is the default value , That is, it doesn't need to be transformed ASCII character . The really common ones are ”quoted-printable” and ”base64″ Two kinds of , Their detailed usage , I will introduce it in detail in tomorrow's notes .

7.

The following is the source code of an email I received :

Date: Wed, 18 Jun 2008 18:07:51 +0800 (CST) From: xxx <[email protected]> To: [email protected] Message-ID: <[email protected]m> Subject: =?gbk?B?xOO6ww==?= MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=&quot;—-=_Part_287491_22998031.1213783671982&quot; ——=_Part_287491_22998031.1213783671982 Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: base64 IAq4+b7dsr+209PQudi55raoo6yyu7XD1Nq12Le9yM66zs341b7Jz7nSz+DTprXEtqvO96Osx+vE 49TaxOO1xLKpv83W0AogIArW0Ln6yr2x6tPvIC0gyO7Su7fltcTN+MLnyNXWvgoKtcS12jEy1cXN vMasyb6z/aOst/HU8s7Sw8fXt76/xOO1xM/gudjU8MjOoaPQu9C7us/X96OhtMvNvMas1Nq4vbz+ wO/D5g== ——=_Part_287491_22998031.1213783671982 Content-Type: text/html; charset=gbk Content-Transfer-Encoding: quoted-printable <DIV>&amp;nbsp;</DIV> <DIV>=B8=F9=BE=DD=B2=BF=B6=D3=D3=D0=B9=D8=B9=E6=B6=A8=A3=AC=B2=BB=B5=C3=D4= =DA=B5=D8=B7=BD=C8=CE=BA=CE=CD=F8=D5=BE=C9=CF=B9=D2=CF=E0=D3=A6=B5=C4=B6=AB= =CE=F7=A3=AC=C7=EB=C4=E3=D4=DA=C4=E3=B5=C4=B2=A9=BF=CD=D6=D0</DIV> <DIV>&amp;nbsp; ……

You can see this letter MIME The sentence is :

MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=”—-=_Part_287491_22998031.1213783671982″

“Content-Type: multipart/alternative;” Indicate the content of this letter , It's plain text and HTML Text blending . The other two possible values are multipart/mixed and multipart/related, respectively ” There are binary contents in the contents of the letter ” and ” The letter is attached ”.

“boundary=”—-=_Part_287491_22998031.1213783671982″ “ The dividing line indicating the contents of different letters is ”—-=_Part_287491_22998031.1213783671982″, It's usually a very long random string .

There are two sub headers in the content of the letter :

Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: base64

and

Content-Type: text/html; charset=gbk Content-Transfer-Encoding: quoted-printable

They show that , The first part is gbk Encoded plain text , The encoding conversion format is base64. The second part is gbk Coded HTML Text , The encoding conversion format is quoted-printable.

( End )

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/120844.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071653297658.html