应用层协议
MIME的头部
MIME Version: 用它区分是标准 RFC822 邮件还是 MIME 邮件 , 假定在标准邮件中不能以该字符串开头。 定义所使用的MIME版本。
Content-Description: ASCII串,对内容的有关描述。
Content-Id: 对content的唯一的标识。
3. Email的格式
Body: 内容是任意的,但必须是7位标准 ASCII字符。
4. 扩展Email的格式
扩展Email称为MIME(Multipurpose Internet Mail Extensions), 最初在RFC 1341中定义,修订版发布在RFC1521 中。主要是针对RFC822 Email中存在 的诸多不足和限制而提出的。
(1)RFC822 Email的缺点
某些实现并没有完全按照的标准。常见的问题 如下: 回车、换行的删除和增加。 超过76个字符时的处理:截断或自动换行。 后面多余空格的删除。 将制表符转换为多个空格。
(2)MIME的处理方法
MIME 利用了 RFC822 的格式 , 但又加入了 一 个 扩展 的 头部 ( 实 际上 是 位于 RFC822 的 header中)。 主要是为了克服RFC822只能传 输标准7位ASCII文本的缺点 , 使Email既可以 传输标准ASCII文本,也可以传输像图片、声 音、各种语言文本等。
Meaning
Email address(es) of primary recipient(s) Email address(es) of secondary recipient(s) Email address(es) for blind carbon copies Person or people who created the message Email address of actual sender Can be used to identify a path back to the sender
0 0
0 0
0 0
0 0
=
Base64编码后的结果只包含可显示的 ASCII字符,其编码效率为75%。
Quoted-printable Encoding
对于小于128的直接使用(不包括3DH, 即“=”), 大于等于128的用“=”后跟其16进 制值表示。
例如:汉字“系统”,其内部编码为 CF BF CDB3, 编码为: =CF=B5=CD=B3; 对 于等号则使用: =3D.
为传输而分割开的邮件
邮件必须从网上获取 按规定顺序的几个独立部分 不同格式的同一邮件
Multipart
alternative
parallel
digest
必须同时读取的几个部分
每一个部分是一个完整的RFC822邮件
Email例子
Message-ID: <003d01c2921a$30d7cfd0$4e03a8c0@tan> From: "gaofx" <gaofx@> To: <gaofx@> Subject: This is test mail. Date: Fri, 22 Nov 2002 19:19:47 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: base64
DQotLS0tLSBPcmlnaW5hbCBNZXNzYWdlIC0tLS0tIA0KRnJvbTogImdhb2Z4IiA8Z2FvZnhAbmVj bWFpbC5uZXUuZWR1LmNuPg0KVG86IDxnYW9meEBuZWNtYWlsLm5ldS5lZHUuY24+DQpTZW50OiBG
51 52 53 54 55 56 57 58 59 5A 61 62 63 64 65 66
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
g h i j k l m n o p q r s t u v
67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76
(3)MIME的头部
RFC 822 headers added by MIME
Header MIME Version: Meaning Identifies the MIME Version Human-readable string telling what is in Content-Description: the message Content-id: Unique identifier Content-Transfer-Encoding: How the body is wrapped for transmission Content-Type: Nature of the message
MIME的头部
Content-Type: 内容的自然特性,如是图片还 是文本等。 分为两个标识: 类型和子类 型,中间用/分开。
Content-Type
内容类型 Text Image Audio 子类型 plain 无格式的文本 说 明
richtext
gif jpegHale Waihona Puke basic有少量格式命令的文本
Email例子
今天下雪了,真好! It is snowy today. I like snow.
5.邮件的传输
邮件的传送是一种client/server的交互。它是基于 tcp协议的。Server在25号端中上监听,有连接请求时, 接受连接,然后传输邮件,传输完毕后再将连接断开。 这是一个纯 ASCII 字符的协议 . 所有的命令和数据均 以标准ASCII字符传输。
GIF格式的静态图像 JPEG格式的静态图像 声音
Video
Application
mpeg
octet-stream Post-script rfc822
MPEG的影片
连续的字节序列 Postscript格式的可打印文档 MIME RFC822邮件
Message
partial
external-body mixed
cmlkYXksIE5vdmVtYmVyIDIyLCAyMDAyIDc6MTkgUE0NClN1YmplY3Q6IFRoaXMgaXMgdGVzdCBt
YWlsLg0KDQoNCj4gvfHM7M/C0anByyzV5rrDIQ0KPiBJdCBpcyBzbm93IHRvZGF5LiBJIGxpa2Ug c25vdy4NCj4gDQo+IA0K .
6-bit value ASCII char Base64 value 6-bit value ASCII char Base64 value 6-bit value ASCII char Base64 value 6-bit value ASCII char Base64 value
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
A B C D E F G H I J K L M N O P
41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Q R S T U V W X Y Z a b c d e f
3. Email的格式
Some fields used in the RFC 822 message header
Header Date: Reply to: Message id: Meaning The date and time the message was sent Email address to which replies should be sent Unique number for referencing this message later Message-id of the message to which this is a In-Reply-To: reply Keywords: User chosen keywords Short summary of the message for the one-line Subject: display
用户发邮件 用 户 用户读邮件 接 口 发出邮件 缓冲区 到来邮件 的邮箱
客户机 (后台 传送)
服务器 (接收 邮件)
外出邮件 的TCP连接 到来邮件 的TCP连接 # 25端口
用户代理
邮件传输代理
2. Internet Email的命令接口
Unix操作系统下EMAIL命令
Command h c t s f a d u m k r n b g e Parameter # # address # # # # # # mailbox Description Display header(s) on the screen Display current header only Type message(s) on the screen Send a message Forward message(s) Answer message(s) Delete message(s) Undelete previously Delete message(s) Move message(s) to another mailbox Keep message(s) after exiting Read a new mailbox Go to next message and display it Backup to the previous message and display it Go to a specific message but not display it Exit the mail system and update the mailbox