SMTP, POP3, IMAP
Electronic Mail
Copyright By PowCoder代写 加微信 powcoder
For each user
outgoing message queue
Three major components:
user mailbox
1. User agents
2. Mail servers mail
user agent
3. Communication protocols (SMTP), POP3 or IMAP
user agent
I. User Agent a.k.a. “mail reader”
user agent
composing, editing, reading, saving, forwarding mail messages
mail server
JK¥yDH
SMTP: push protocol
end of message
TCP connection is initiated by the machine that wants to send the file.
Server Server
Client Server
Application 2-10
SMTP: final words
Comparison with HTTP: HTTP: pull
SMTP: push
both have ASCII command/response interaction,
status codes
SMTP is older (1982) than HTTP (1996)
HTTP: each object encapsulated in its own response msg
SMTP: multiple objects sent in one multipart msg
Application 2-11
Mail message format
SMTP: defines protocol for email msg transport, but not the content.
RFC 5322: defines standard for text message format:
blank line
header lines, e.g., From:
Subject:
different from SMTP commands! body
the “message”, ASCII characters only
Application 2-12
Message format: multimedia extensions
MIME: Multipurpose Internet Mail Extensions (1991) (RFC 2045, 2056)
additional lines in msg header declare MIME content type
MIME version
Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg
method used to encode data
multimedia dataType (RFC 1521), subtype, parameter declaration
base64 encoded data ….. ……………………. ……base64 encoded data
encoded data
MIME types
Content-Type: type/subtype; parameters
example subtypes: plain, html
example subtypes: mpeg, quicktime
Application
example subtypes: jpeg, gif
other data that must be processed by reader before “viewable”
example subtypes: msword, octet-stream
example subtypes: basic
(8-bit mu-law encoded), 32kadpcm (32 kbps coding)
Multipart Type
Please find a picture of a
How can we send an email that comes with a combination of text and image?
Please find a picture of a crepe. –98766789 Content-Transfer-Encoding: base64 Content-Type: image/jpeg
base64 encoded data …..
…………………….
……base64 encoded data
–98766789–
Multipart Type
Subject: Picture of yummy crepe.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=98766789
–98766789
Content-Transfer-Encoding: quoted-printable Content-Type: text/plain
Header area Blank line
Header area Blank line
Mail access protocols
SMTP SMTP user HTTP
user agent
protocol POP3, IMAP, HTTP
sender’s mail server
receiver’s mail server
SMTP: delivery/storage to receiver’s server mail access protocol: retrieval from server
POP3: Post Office Protocol [RFC 1939]
• authorization (agent <-->server) and download
IMAP: Internet Mail Access Protocol [RFC 1730] • more features (more complex)
• manipulation of stored messages on server
HTTP: Gmail, Hotmail, Yahoo! Mail, etc.
Application 2-17
POP3 protocol (TCP, port 110)
authorization phase
Example: download and delete mode
client commands:
user: declare username pass: password
S: +OK POP3 server ready
C: user bob
C: pass hungry
server responses +OK
S: +OK user successfully logged on
transaction phase, client:
S:
S:
S: +OK POP3 server signing off
list: list message numbers
retr: retrieve message by number
dele: delete
update phase – occurs after
the quit command
POP3 protocol: APOP (RFC 1460) APOP
• An alternative method of authentication that provides for both origin authentication and replay protection, but which does not involve sending a password in the clear over the network.
• S: Server includes a timestamp in its banner greeting.
POP3 server verifies the digest provided. If the digest is correct, the POP3 server issues a positive response, and the POP3 session enters the TRANSACTION state. Otherwise, a negative response is issued and the POP3 session remains in the AUTHORIZATION state.
• C: The POP3 client makes note of this timestamp, and then issues the APOP command.
APOP name digest
Example: APOP authentication
timestamp digest
S: +OK POP3 server ready C: APOP nhreyes c4c9334bac560ecc979e58001b3e22fb
S: +OK maildrop has 1 message (369 octets)
• Arguments: a server specific user-id and a digest string (both required).
POP3 protocol: APOP (RFC 1460) APOP
• An alternative method of authentication that provides for both origin authentication and replay protection, but which does not involve sending a password in the clear over the network.
Example: APOP authentication
timestamp digest
S: +OK POP3 server ready C: APOP nhreyes c4c9334bac560ecc979e58001b3e22fb
S: +OK maildrop has 1 message (369 octets)
• The digest parameter is calculated by applying the MD5 algorithm [RFC1321] to
a string consisting of the timestamp (including angle-brackets) followed by a shared secret.
POP3 protocol: APOP (RFC 1460) Server includes a timestamp in its banner greeting.
The POP3 client makes note of this timestamp, and then issues the APOP command.
Command: APOP name digest
• Arguments: a server specific user-id and a digest string (both required).
In this example, the shared secret is the string “tanstaaf”.
• The digest parameter is calculated by applying the MD5 algorithm [RFC1321] to a string consisting of the timestamp (including angle-brackets) followed by a shared secret.
Hence, the MD5 algorithm is applied to the string
Example: APOP authentication
timestamp digest
S: +OK POP3 server ready C: APOP nhreyes c4c9334bac560ecc979e58001b3e22fb
S: +OK maildrop has 1 message (369 octets)
which produces a digest value of
c4c9334bac560ecc979e58001b3e22fb
POP3 (more) and IMAP
more about POP3
No concept of folders
designed to permit manipulation of remote mailboxes as if they were local
previous example uses “download and delete” mode.
Defaults to keeping all messages in one place: at server; simply downloading a local copy
Bob cannot re-read e-mail if he changes client
“download-and-keep”: copies of messages on different clients
allows user to organize messages in folders
POP3 is stateless across sessions
Selected components of messages can be obtained
currently supports several authentication methods (e.g. APOP protocol used by Mozilla Thunderbird, , Windows Live Mail, etc.)
names of folders and mappings between message IDs and folder name
keeps user state across sessions:
simultaneous access to the same
mailbox by multiple agents
Application 2-22
2: Application Layer 23
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com