Javamail format and corresponding Encoding

Source: Internet
Author: User

Recently, it has been plagued by problems such as javamail format and corresponding encoding.
It has been so embarrassing that it is better to die.

This is just some time in the afternoon. Here we will make some simple summary of javamail, so as to provide some reference for future work.

First, define a concept: mime, all called "Multipurpose Internet Mail Extensions". The exact Chinese name is "multi-purpose Internet Mail Extension ".
It is a widely used email technical specification. Its basic content is defined in RFC 2045-2049.

The following is a summary of the basic types of mail.

First:
Name: text/plain

Content-Type: text/plain;
Format = flowed;
Charset = "iso-2022-jp ";
Reply-type = original
Content-transfer-encoding: 7bit

It only contains plain text, basically in RFC 822 format;

Type 2: multipart/mixed (type 1: Add a file)

Content-Type: multipart/mixed;
Boundary = "---- = _ nextpart_000_01231601c7fc71.8e404870"
==================

This is a multi-part message in MIME format.
// The content and format of the mail body text are as follows:
------ = _ Nextpart_000_01231601c7fc71.8e404870
Content-Type: text/plain;
Format = flowed;
Charset = "iso-2022-jp ";
Reply-type = original
Content-transfer-encoding: 7bit

// The following should be the content and format of the attached file added by mail.
------ = _ Nextpart_000_01231601c7fc71.8e404870
Content-Type: Application/octet-stream;
Name = "test. Java"
Content-transfer-encoding: quoted-printable
Content-Disposition: attachment;
Filename = "test. Java"

Third: multipart/alternative (an HTML file)

Content-Type: multipart/alternative;
Boundary = "---- = _ nextpart_000_0130_01c7fc72.98622a70"

This is a multi-part message in MIME format.
// Why is the format text/plain? I don't understand.
------ = _ Nextpart_000_0130_01c7fc72.98622a70
Content-Type: text/plain;
Charset = "iso-2022-jp"
Content-transfer-encoding: quoted-printable

// What makes me feel strange?

------ = _ Nextpart_000_0130_01c7fc72.98622a70
Content-Type: text/html;
Charset = "iso-2022-jp"
Content-transfer-encoding: quoted-printable

<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML> <Meta http-equiv = 3dcontent-type content = 3D "text/html; =
Charset = 3diso-2022-jp ">
<Meta content = 3D "mshtml 6.00.2900.2912" name = 3 dgenerator>
<Style> </style>
</Head>
.....

The fourth type: multipart/mixed (the third type + one additional file). In this case, all emails with additional files are in this format.
Content-Type: multipart/mixed;
Boundary = "---- = _ nextpart_000_013b_01c7fc73.31485110"

This is a multi-part message in MIME format.
// What is this?

------ = _ Nextpart_000_013b_01c7fc73.31485110
Content-Type: multipart/alternative;
Boundary = "---- = _ nextpart_000000013c_01c7fc73.31485110"

------ = _ Nextpart_000000013c_01c7fc73.31485110
Content-Type: text/plain;
Charset = "iso-2022-jp"
Content-transfer-encoding: quoted-printable

// Why?
------ = _ Nextpart_000000013c_01c7fc73.31485110
Content-Type: text/html;
Charset = "iso-2022-jp"
Content-transfer-encoding: quoted-printable

// This is the format of the attached file.

------ = _ Nextpart_000_013b_01c7fc73.31485110
Content-Type: Application/octet-stream;
Name = "test. Java"
Content-transfer-encoding: quoted-printable
Content-Disposition: attachment;
Filename = "test. Java"

The above is so far quite confusing

I saw a good thing today: I recommend it.

Http://dev.csdn.net/article/18/18448.shtm

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.