MIME and Transfer Encoding

3
E-Mail Message Format
• SMTP: protocol for
exchanging email messages
• RFC 822: standard for text
message format:
• header lines, e.g.,
MIME
and
Transfer Encoding
– To:
– From:
– Subject:
– Message ID
– Date
– Received
– X-priority
• body
– the “message”, 7-bit ASCII
characters only
MIME
3
1
blank line
encoded data
MIME
2
Audio
1. Rxer convert msg’s body to • exampe subtypes: basic (8-bit
mu-law encoded), 32k ADPCM
its original non-ASCII first
(32 kbps coding)
2. Then, uses type to determine Video
what actions it should take
• example subtypes: mpeg,
quicktime
Type/subtype :
Application
Text
• other data that must be
• example subtypes: plain, html
processed by reader before
Image
“viewable”
• example subtypes: jpeg, gif
• example subtypes: msword,
octet-stream, pdf, ps
base64 encoded data .....
.........................
......base64 encoded data
(RFC 2045/46 for more on headers)
MIME
Content-Transfer-Encoding: base 64
(header lines)
multimedia data
type, subtype,
parameter declaration
(details on next page)
Content-Type: type/subtype; parameters
(generated by user agent)
method used
to encode data
body
MIME (Multipurpose Internet Mail Extensions) Types
• MIME: Multimedia Internet Mail Extension, RFC 2045-49, 2056
~ an extension of RFC 822 for resolving prob. in SMTP/822 scheme
• additional lines in msg header declare MIME content type
From: [email protected]
To: [email protected]
Subject: Test of E-Mail.
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Type: image/jpeg
blank
line
3
Message Format: Multimedia Extensions
MIME version
header
3
MIME(To
register Types to IANA: see RFC 2048)
4
3
MIME References
From: [email protected]
To: [email protected]
Subject: test of multipart type
(containing many objects)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=98766789
• RFC 2045 – MIME (Multipurpose Internet Mail Extensions) Part
One: Format of Internet Message Bodies
• RFC 2046 – MIME (Multipurpose Internet Mail Extensions) Part
Two: Media Types
• RFC 2047 – MIME (Multipurpose Internet Mail Extensions) Part
Three: Message Header Extensions for Non-ASCII Text
• RFC 2048 – MIME (Multipurpose Internet Mail Extensions) Part
Four: Registration Procedures
• RFC 2049 – MIME (Multipurpose Internet Mail Extensions) Part
Five: Conformance Criteria and Examples
• RFC 2156 – MIXER (MIME Internet X.400 Enhanced Relay):
Mapping between X.400 and RFC 822/MIME
• RFC 2159 – A MIME Body Part for FAX
• RFC 2183 – Communicating Presentation Information in Internet
Messages
• RFC 2231 – MIME Parameter Value and Encoded Word Extensions
MIME
Example - Multipart Type
Part I
--98766789 Å Separation begin with “ - - ”
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain
Dear ALL,
end with “ CR LF ”
Please study hard on Networking course. °
--98766789
Content-Transfer-Encoding: base64
Content-Type: image/jpeg
Part II
5
MIME
base64 encoded data .....
.........................
......base64 encoded data
--98766789-- Å End of the last part
6
3
Transfer Encoding Selection
MIME Content - Transfer Encoding
• Transfer encodings for message bodies to provide reliable
delivery across the largest networking environment Å provide
human readable and reasonable compact
Example - Outlook Express
Encoding Schemes
No
encoding
Choose here
(x ~ vender/application specific)
MIME
7
MIME
8
3
“Quoted” means . . .
Quoted-Printable Encoding
•
Encoding data consisting largely of printable ASCII characters
~ represents non-mail safe characters by hexadecimal
representation of their code and introduce reversible (soft) line
breaks to limit message lines to 76 characters (or less).
• Q.P. encoding rules:
– General 8-bit representation
~ used when none of following rules apply Explained
– Literal representation
next page
– White space
– Line breaks
~ use “ CR LF ” combination (i.e., 0D0AH)
“ =”
– Soft line breaks
~ for lines > 76 char., (excluding CR,LF), inserts “ 3D0D0A ” at
or before character position 75 (called soft line break).
• Using the equal sign (“ = ”) as a quote
character to indicate both the non-mail
safe characters and soft line break
• Quoted-printable is an encoding using ASCII characters
for non-ASCII text. It is defined as a MIME content
transfer encoding for use in Internet e-mail.
MIME
3
9
MIME
3
Quoted-Printable Encoding (cont’d)
• General 8-bit representation
– any character Æ “=” + “ two-digit hexadecimal representation of
the octet’s value ”
– Ex: 8-bit value “12” Æ “=0C”
• Literal representation
– any character in the decimal range 33 (“!”, 21H) to 126(“~”, 7EH)
Æ represented as that ASCII character
– Exception: 61 (“=”, 3DH)
MIME
11
Base64/Radix-64 Encoding
• Encoding arbitrary binary data to be invulnerable to the processing
by mail transport programs : that does not consist mainly of text characters
- Process in a 3-octet (24-bit) basis
- every 6-bit mapped to 8-bit codeword/character
No “-” ;
No ctrl
char.
• White space
– “tab” Æ octet value : 9 (<tab>)
IRA
– “blank” Æ octet value : 32 (<sp>)
– Exception: “tab” and “blank” at the end of a line
example
Æ (encoding) using Gen. 8-bit repre.
(decoding) delete any trailing white space (HT and BS)
10
(26 + 1)’s
RFC
1421,
2045
printable
characters
Ex.
MIME
12
3
Base-64 Example
6-bit
6-bit
6-bit
E-mail in Details
6-bit
• Example
Press Right
botton
If Double
clicking
IRA
00100011 01011100 10010001
base64
base64
base64
base64
Char. 1 Char. 2 Char. 3 Char. 4
↓
001000 110101 110010 010001
↓
I
1
y
R
A block of 24-bit raw data
4 characters for transferring
* no control characters in the set for
traversing mail-handling systems that
scan the data for control characters.
MIME
E-mail Example – 1
(7-bit ASCII)
13
Example – 2 (base64)
From: "kai-wei ke" <[email protected]>
To: <[email protected]>
Cc: "Elton John" <[email protected]>
Subject: Mail test
Date: Sun, 17 Mar 2002 22:09:43 +0800
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="---=_NextPart_000_0009_01C1CE00.713E1360"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE
V6.00.2600.0000
------=_NextPart_000_0075_01C1CE05.F702D1C0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: base64
This is a test of MIME encoding stuff.
You must look at the encoded form for details.
Exercise
VGhpcyBpcyBhIHRlc3Qgb2YgTUlNRSBlbmNvZGluZyBzdHVmZi4NCllvdSBtdXN0IGxvb2sgYXQg
dGhlIGVuY29kZWQgZm9ybSBmb3IgZGV0YWlscy4NCg0KS2FpLVdlaQ==
Kai-Wei
= NextPart 000 0009 01C1CE00 713E1360
Content-Type: text/plain;
Ex-1(cont’d)
name="test.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="test.txt"
This is a multi-part message in MIME format.
------=_NextPart_000_0009_01C1CE00.713E1360
Content-Type: text/plain;
charset="big5"
Content-Transfer-Encoding: 7bit
(cont’d on next page)
14
From: "kai-wei ke" <[email protected]>
To: <[email protected]>
Cc: "Elton John" <[email protected]>
Subject: Mail test
This is a test of MIME attachment.
Date: Sun, 17 Mar 2002 22:49:15 +0800
MIME-Version: 1.0
------=_NextPart_000_0009_01C1CE00.713E1360-Content-Type: multipart/mixed;
boundary="----=_NextPart_000_0075_01C1CE05.F702D1C0"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
This is a multi-part message in MIME format.
MIME
(next pages)
MIME
------=_NextPart_000_0075_01C1CE05.F702D1C0
15
MIME
16
3
QP Example
International Reference Alphabet
(or IAC)
← = 4 blank
← 7 blank follows
Vertical
Formatting
Control
characters
MIME
17
MIME
For 8-bit ASCII, b8 Æeven/odd parity bit or just zero
IRA Control Characters
18
IRA Control Characters
Information Separator
Format Control
Transmission Control
MIME
19
Miscellaneous
MIME
20
American Standard Code for Information Interchange (ASCII)
ASCII
control characters
MIME
21
MIME
22