Title: MIME Multipurpose Internet Mail Extensions
1MIMEMultipurpose Internet Mail Extensions
????????
?????? ?????? ??????? ?? ??
2????
1. MIME???RFC
2. ????????????(RFC822)
3. MIME(RFC2045)
4. ??(Sylpheed)
3MIME???RFC
1982?
RFC822 Standard for APRA Internet Text
Massages RFC2045 MIME Part One Format of
Internet Message Bodies RFC2046 MIME Part Two
Media Types RFC2047 MIME Part Three Message
Header Extensions for
Non-ASCII Text RFC2048 MIME
Part Four Registration Procedures RFC2049 MIME
Part Five Conformance Criteria and Examples
1996?
4????????????(RFC822)
??????????????????
ASCII???(7??????) ???
??4???
??4???
???????????????????????????
5???????????????
???????????????????????
?????????????????? ??????????????(CRLF????)??????
??????????????????????? ?????????????????????
(1) ???????????????
????????????????????????
(2) ?????????
???????ASCII???? ?????????????(?????CRLF)
RFC821(SMTP)????????????? 1????1000???(CRLF???)?
??
(???80???????)
6??????
(1)?????
(3)??????
Date???? To???????? From???(???) Sender??????
)
Return-Path??????? MAIL
FROM ??? Received?????? Message-ID????????????
????????????
(
(2)????????
(4)????????
Cc??????? Bcc????????
????????? Subject?? Reply-to ?????? Comment
???? Keyword????? Encrypted???(???)
X- ????ASCII?? (??????0x210x7E)
?????????(?????)?????????????
7???????????
?????
????????? (1) US-ASCII???????????????(256????) (2)
????????(1????72????)
CRLF?????????????????????? ????????????????????
????? ????????????????? ????????????????????????
?? ????
??????
??????????????????
8??????????????
Return-Path ltd_yano_at_test.csce.kyushu-u.ac.jpgt Rec
eived from crest (hisame.csce.kyushu-u.ac.jp
133.5.22.121) by crest.csce.kyushu-u.ac.
jp (8.9.33.2W/3.7W99041514) with ESMTP id
W\ AA03253 for ltd_yano_at_test.csce.kyushu-u.
ac.jpgt Fri, 04 Jan 2002 124947 0900 (JS\ T)
Message-Id lt20020104124553.55B3.D_YANO_at_test.csce
.kyushu-u.ac.jpgt X-UIDL A'A!!7!!5e"!/"c!! Subj
ect test mail From d_yano ltd_yano_at_test.csce.kyus
hu-u.ac.jpgt To d_yano ltd_yano_at_test.csce.kyushu-u.
ac.jpgt Date Fri, 04 Jan 2002 124947 0900
???
??(CRLF????)
Hi! This is a simple text message.
??
9MIME
?????????????????????????
??????????????????(???????) ????????????????(8????
??)
????????????????????
MIME(Multipurpose Internet Mail Extensions)
????????8?????????????????? ???????????
??????????????????????????????? ??????? ??????US-A
SCII????????????????????
10MIME???????????
MIME??????????????????????????
??????????????????????
(1)????????MIME?????????? (2)??????????????
??????????????
MIME???????????????????? ??????????????? ?????????
MIME????????? ?????US-ASCII???????????????
11MIME????????
(1)MIME????????
RFC822????????????????????
MIME-Version Content-Type Content-Transfer-Encodin
g Content-ID Content-Description Content-Dispositi
on
(2)MIME??????
?????????????????????????? ??????????????????????
MIME-Version ???MIME????????
? MIME????????? Content- ????
? MIME??????????????????
12MIME-Version
??????MIME??????????????????? ??????????????MIME??
??????? ?????MIME???????1.0??????? MIME???????????
???????????????
MIME-Version 1.0
13Content-Type(1)
???MUA(Mail User Agent)????????????????? ?????????
?????????????????????? ????????????????(RFC2046)??
??? ?????????????????????????? ???????????????????
??
Content-Type ???????/?????????????????
Content-Type????????????????????? ???????
Content-Type text/plain charsetus-ascii
? ???????????????????????????????
14Content-Type(2)
???????(RFC2046)
Discrete Media Type (1) text????????HTML???????
?????? (2) imageGIF?JPG???????? (3)
audioWAVE???????? (4) videoMPEG???????? (5)
application?????????????? Composite Media Type
(6) multipart???????????? (7)
messageRFC822???????????????
? ??????????????????????? application/octet-s
tream????????????
15Content-Type(3)
?????
????????????????????? ??????????1??????????????? ?
?????? ??????????????? (1) RFC2048?????IANA(Inter
net Assigned Number Authority)?????
(2) ?????????X-??????????
?????
???????????????? ??????????????????????????? ?????
????????????????????
? multipart ?????????????????boundary ?????
text ?????????????????charset ?????
?????
16Content-Type(4)
MIME?????(RFC2046)
MIME????????????????????????? 7???US-ASCII????????
????? ??????????????????????
Content-Type multipart/mixed boundaryboundary_
str
1???????????????????
--boundary_str
???????????????????????
--boundary_str--
???????????????????????????? ???????????????
? MIME??????????????????????????
17Content-Transfer-Encoding
??????????????????????????? ?????????????????????
Content-Transfer-Encoding ???????
???????????????? (1) 7bit ???7bit???????????????
(2) 8bit ???8bit??????????????? (3) binary
?????????????????????? (4) quoted-printable
quoted printable??????(7bit) (5) base64
base64??????(7bit)
Content-Type?multipart???message????? 7bit?8bit?bi
nary???????????????
? ????????????????????????
18Content-ID
???????????????????????????? ?????????????????????
??? ????????????????????
? Content-ID ltid42_at_guppylake.bellcore.comgt
Content-ID????????????massege/external-body? ?????
????(RFC2046)
19Content-Description
US-ASCII?????????????????????? ????????? Content-D
escription????????????
? Content-Description The attachment below is
PGP-encoded.
??????????????US-ASCII???????? ???????????????????
?????????
??????ASCII?????????(RFC2047)
???????
???????????????????????????
? ?????? Content-Description ??? ??????
Content-Description ?iso-2022-jp?B?GyRCRnxLXDhsG
yhC?
? ?????????MIME???????????????????
20Content-Disposition(RFC2183)
???????????????????????????? ?????????????????????
Content-Disposition ???????????????
????????????? (1) inline??????????????????????
(2) attachment????????????
????????filename??????filename??????? ????????????
?????
21MIME???????
From xx_at_xx.xx To abc_at_xyz.com Subject
?ISO-2022-JP? Date Sun, 01 Sep 2001 151515
0900 Mime-Version 1.0 Content-Type
Multipart/Mixed boundaryBoundary
????????
--Boundary Content-Type Text/Plan
charsetiso-2022-jp Content-Transfer-Encodeing
7bit
???
MIME ???
?????????
??
--Boundary Content-Type Image/Gif
namexx.gif Content-Transfer-Encodeing
base64 Content-Disposition attachment
filenamexx.gif
??
MIME ???
???????????
--Boundary--
22MIME?????
?????????????????????????????? ????US-ASCII???????
????????US-ASCII???? ?????????????
?????????? (1) 7bit?8bit?binary
???????????????????? (2) quoted-printable
????7??????????? (3) base64
????7???????????
237bit?8bit?binary
7??????
RFC821????????US-ASCII??????? 10?US-ASCII?????0???
128????????????????? CR?LF???????CRLF?????????????
??
8??????
10???128???US-ASCII?????????????7?????????
???????
US-ASCII??????????????????????????????
??????????????(SMTP)?????????? ??????????????????7
????????
8???????????????????????
8???????????????quoted-printable??? base64????????
7????????
24quoted-printable
????????(US-ASCII????)???? 7??????????????????????
??
???????????????????????? ?????US-ASCII????????????
??
???? quoted-printable ?????????????
25quoted-printable?????????
????????
(1) ????????????????????????????????
????????????????
(2) ????????????(CRLF)????????????()???
???????????16??(0123456789ABCDEF)2??????????
??????????(abcdef)???????
(3) US-ASCII10?????3360???62126????????US-ASCII?
? ???????????????
(4)????(US-ASCII10?????9???????32?????)??????
???????????????????????????????(2)???
(5) ?????????????CRLF????????
(6) ???76?????????????(???CRLF?????)??????
??????76????????????()???CRLF????????
????????????????????????
26quoted-printable?????????
The Quoted-Printable encoding requires that
encoded lines be no more than 76 characters long.
gt RFC2045
???16???????????(2) ???????????(3) ???????????????
?????????????(4) ????????????????????(5) 76???????
?????????????????????
The Quoted-Printable encoding requires that
encoded lines be no more than 76 characters
long. 3D3Dgt RFC2045
27base64
7bit???quoted-printable????????????? ????(????????
?)??????????? ????????????????????????
7?????????????????7?????????? ????quoted-printable
??????????????? ??????????
?????????????????????????? 33????
28base64?????????
????????
(1) ???????????????????????????????
???????????????
(2) ????????????????????????????CRLF?????
(3) ???????3?????????????6?????????base64????
????????????
(4) ???(3)??????4??6????????????????4?????
????
(5) ????????????????????(CRLF)????76?????
???????
(6) ?????????????????1????2??????????????
???????????????????????????
(7) ??????????????6??????????????0?????
?????????6???????????(3)???????????????
??????????4????????????1????2????()?
??????
29base64???
??()???????????????
30base64?????????
? GIF89?base64??????????
1. ??????????????
0100011101001001010001100011100000111001
2. ??????6 ???????????
010001 110100 100101 000110 001110 000011
1001
3. ????????6 ????????0???????
010001 110100 100101 000110 001110 000011
1000100
4. 6 ?????????64????????
10???
17 52 37 6 14
3 36
????
R 0 l G
O D k
5. ???????4????????????????
R 0 l G
O D k
6. ??
R01GODK
31??
Sylpheed (1) X Window System??????
??????????? ???????? (2) Linux ?????? POSIX
??? Unix like OS ? ???? (3) MIME??
32??????
compose.c
fprintf(fp, "\n--s\n", compose-gtboundary)
conv_encode_header(fi
lename, sizeof(filename),ainfo-gtname, 12)
fprintf(fp, "Content-Type s\n"
" name\"s\"\n",
ainfo-gtcontent_type,
filename) fprintf(fp,
"Content-Disposition attachment\n"
" filename\"s\"\n",
filename)
fprintf(fp, "Content-Transfer-Encoding s\n\n",
procmime_get_encoding_str(a
info-gtencoding)) if (ainfo-gtencoding
ENC_7BIT)
fputs(buf, fp)
else
to64frombits(outbuf, inbuf, B64_LINE_SIZE)
fputs(outbuf, fp)
fprintf(fp, "\n--s--\n",
compose-gtboundary)
33????(1)
34????(2)
Date Fri, 04 Jan 2002 003216 0900 From
d_yano ltd_yano_at_swlab.csce.kyushu-u.ac.jpgt To
d_yano ltd_yano_at_swlab.csce.kyushu-u.ac.jpgt Subject
?ISO-2022-JP?B?TUlNRRskQiVhJUMlOyE8JTgbKEI? Me
ssage-Id lt20020104003216.5f66fd9a.d_yano_at_swlab.cs
ce.kyushu-u.ac.jpgt Mime-Version
1.0 Content-Type multipart/mixed
boundary"Multipart_Fri__04_Jan_2002_003216_090
0_082a6640" This is a multi-part message in MIME
format. --Multipart_Fri__04_Jan_2002_003216_09
00_082a6640 Content-Type text/plain
charsetISO-2022-JP Content-Transfer-Encoding
7bit MIME???????????? --Multipart_Fri__04_Jan_2
002_003216_0900_082a6640 Content-Type
image/jpeg name"?ISO-2022-JP?B?GyRCMmhBfBsoQ
i5qcGc?" Content-Disposition attachment
filename"?ISO-2022-JP?B?GyRCMmhBfBsoQi5qcGc?"
Content-Transfer-Encoding base64 /9j/4AAQSkZJRgA
BAQEAAQABAAD//gAplceOhk1ha2VyIFByb4Fpjo6XcJTFgWqCx
Y3skKyCtYLc VuPsLgyMdaQrJxrW77kHHMJmmm02fhpn/Ci1
xwcHpP71Lj3fxmiv/9k --Multipart_Fri__04_Jan_2002
_003216_0900_082a6640--