首先明确一个概念:MIME, 全称为"Multipurpose Internet Mail Extensions", 比较确切的中文名称为"多用途互联网邮件扩展"。
它是当前广泛应用的一种电子邮件技术规范,基本内容定义于RFC 2045-2049。
以下来总结mail的基本类型
第一种:
名称:text/plain
Content-Type: text/plain;
format=flowed;
charset="iso-2022-jp";
reply-type=original
Content-Transfer-Encoding: 7bit
只带纯文本正文,基本上就是RFC 822格式;
第二种:multipart/mixed(第一种 + 一本添附文件)
Content-Type: multipart/mixed;
boundary="----=_NextPart_000<wbr></wbr>_0121_01C7FC71.8E404870"
=============
This is a multi-part message in MIME format.
// 下面这个应该就是mail正文文本的内容和格式
------=_NextPart_000_0121<wbr></wbr>_01C7FC71.8E404870
Content-Type: text/plain;
format=flowed;
charset="iso-2022-jp";
reply-type=original
Content-Transfer-Encoding: 7bit
// 下面这个应该就是mail的添附文件的内容和格式
------=_NextPart_000_0121<wbr></wbr>_01C7FC71.8E404870
Content-Type: application/octet-stream;
name="Test.java"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="Test.java"
第三种:multipart/alternative<wbr></wbr>(就是所谓的html格式的文件)
Content-Type: multipart/alternative;
boundary="----=_NextPart_000<wbr></wbr>_0130_01C7FC72.98622A70"
This is a multi-part message in MIME format.
// 为什么格式是text/plain呢?不明白。
------=_NextPart_000_0130<wbr></wbr>_01C7FC72.98622A70
Content-Type: text/plain;
charset="iso-2022-jp"
Content-Transfer-Encoding: quoted-printable <script type="text/javascript"><!-- --></script>
// 再接下来的东西就更加让我觉得奇怪了?
------=_NextPart_000_0130<wbr></wbr>_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><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-2022-jp">
<META content=3D"MSHTML 6.00.2900.2912" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
。。。。。
第四种:multipart/mixed(就是第三种 + 一个添附文件)这样看来,所有带添附文件的mail都是这样的格式<wbr></wbr>的了。
Content-Type: multipart/mixed;
boundary="----=_NextPart_000<wbr></wbr>_013B_01C7FC73.31485110"
This is a multi-part message in MIME format.
// 这是什么东西?
------=_NextPart_000_013B<wbr></wbr>_01C7FC73.31485110
Content-Type: multipart/alternative;
boundary="----=_NextPart_001<wbr></wbr>_013C_01C7FC73.31485110"
------=_NextPart_001_013C<wbr></wbr>_01C7FC73.31485110
Content-Type: text/plain;
charset="iso-2022-jp"
Content-Transfer-Encoding: quoted-printable
// 怎么还有?
------=_NextPart_001_013C<wbr></wbr>_01C7FC73.31485110
Content-Type: text/html;
charset="iso-2022-jp"
Content-Transfer-Encoding: quoted-printable
// 这个属于添附文件的格式。
------=_NextPart_000_013B<wbr></wbr>_01C7FC73.31485110
Content-Type: application/octet-stream;
name="Test.java"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename=" Test.java"
上面的东西目前为止相当的困惑
今天看到一个好东西:推荐一下
http://dev.csdn.net/article/18<wbr></wbr>/18448.shtm
<script type="text/javascript"></script>