SMTP电子邮件格式及源码解析

SMTP协议之电子邮件格式

以下是使用FOXMAIL接收邮件后,得到的邮件源码,包括正文和两个附件(.JPG, .TXT):


----------------------------------------------------------------

以下部分为邮件服务器添加的邮件头

----------------------------------------------------------------

Received:from m15-17.126.com (unknown [220.181.15.17])

         bymx10 (Coremail) with SMTP id PMCowECZWSfPlodRSu6NCw--.779S2;

         Mon,06 May 2013 19:41:03 +0800 (CST)

DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; // 域名密钥识别邮件标准,判断垃圾邮件

         s=s110527;h=Received:Date:From:To:Subject:Content-Type:

         MIME-Version:Message-ID; bh=B57Zfi/+wCVQ61kM9GVkCECk1ax4OZVQDtnW // 不是base64编码

         T4lS0x8=;b=XdeYidC7bR1a1l7x3yGAMiMR5ElDx2O4/db2iPrVc0dZ7Y7ANStu     // 不是base64编码

         6d9o4l9yVysfwk8vifb0eqyxV2wp28pIlfLEGZbDDpKaLMCaLAbVXdW+2hQl4ojd    // 不是base64编码

         sJ7NiAdF1j5X2N87wktFKA8ZK4lPhBYI1yFrNIT+PODg2NzF1CX2FDM=

Received: from zzzzyy91$126.com ( [202.205.103.22] ) by ajax-webmail-wmsvr17

 (Coremail) ; Mon, 6 May 2013 19:41:01 +0800(CST)

X-Originating-IP: [202.205.103.22]                //初始ip地址,同一电脑不同邮箱发邮件,该值相同

---------------------------------------------------------------------------------------------------------

DATA(以下内容由邮件客户端定义,为DATA命令后输入的内容)

灰色高亮为主要内容

--------------------------------------------------------------------------------------------------------

 

Date: Mon, 6 May2013 19:41:01 +0800 (CST)

From: [base64code]<zzzzyy91@126.com>

To: [emailaddress]

Subject: [base64 code]

X-Priority: [integer]                                          // 邮件优先级

X-Mailer: [Coremail Webmail Server Version SP_ntes V3.5 build      // 代理发信客户端

 20130412(21945.5326.5325) Copyright (c)2002-2013 www.mailtech.cn 126com]

X-CM-CTRLDATA: [base64 code]                           // X-邮件服务器自定义的信息段,未知作用

Content-Type:multipart/mixed;                               // 声明邮件内容格式

         boundary="----=_Part_354288_309861106.1367840461937"    // 声明邮件内容boundary

MIME-Version: 1.0                                          // 声明MIME版本

Message-ID: <>                                             // X-邮件服务器自定义的信息段

X-CM-TRANSID:                                             //X-邮件服务器自定义的信息段

X-CM-SenderInfo:                                           // X-邮件服务器自定义的信息段

X-Coremail-Antispam:                                       // X-邮件服务器自定义的信息段

 

---------------------------------------------------------

以下为邮件的内容

黄色高亮部分为内容说明语句和定界符

绿色高亮部分为邮件内容

蓝色高亮部分为附件内容

--------------------------------------------------------

 

------=_Part_354288_309861106.1367840461937                 //邮件内容开始

Content-Type: multipart/alternative;                           //邮件内容格式

         boundary="----=_Part_354290_1105600126.1367840461937" // 邮件正文boundary

 

------=_Part_354290_1105600126.1367840461937              //邮件正文boundary -- 正文开始

Content-Type: text/plain; charset=GBK                        // 邮件正文格式和字符集

Content-Transfer-Encoding: base64

 

[base64]mailcontent (plain)[base64]                         //邮件正文(文本格式)编码(base64

 

------=_Part_354290_1105600126.1367840461937              // 邮件正文boundary  --可选HTML格式

Content-Type: text/html; charset=GBK                        //邮件正文格式和字符集

Content-Transfer-Encoding: base64

 

[base64]mailcontent (html)[base64]                         //邮件正文(html格式)编码(base64

 

------=_Part_354290_1105600126.1367840461937--           // 邮件正文boundary -- 正文结束

 

 

------=_Part_354288_309861106.1367840461937             // 邮件内容boundary -- 附件1开始

Content-Type: image/jpeg; name="20130324_224528_982.jpg" // 附件格式及文件名

Content-Transfer-Encoding: base64

Content-Disposition: attachment;filename="20130324_224528_982.jpg"

 

[base64](.jpg)image attachment[base64]                         //附件-图片内容编码(base64

 

------=_Part_354288_309861106.1367840461937                  // 邮件内容boundary -- 附件2开始

Content-Type: text/plain; name="window data type.txt"            // 附件格式及文件名

Content-Transfer-Encoding: base64

Content-Disposition: attachment; filename="window datatype.txt"

 

[base64](.txt)plain attachment[base64]                         // 附件-文本内容编码(base64

 

------=_Part_354288_309861106.1367840461937--                // 邮件内容boundary  -- 附件结束

没有更多推荐了,返回首页