SMTP & Pop3
SMTP & Pop3
SMTP & Pop3
2: Application2 Layer
Electronic Mail outgoing
message queue
user mailbox
user
• Three major components: agent
user agents
mail
user
mail servers server
agent
simple mail transfer protocol: SMTP
SMTP mail
server user
SMTP agent
User Agent
a.k.a. “mail reader” SMTP
composing, editing, reading mail mail
user
messages agent
server
e.g., Eudora, Outlook, elm,
user
Mozilla Thunderbird
agent
outgoing, incoming messages user
stored on server agent
2: Application3 Layer
Electronic Mail: mail servers
server
user
agent
user
agent
2: Application4 Layer
Electronic Mail: SMTP [RFC 2821]
uses TCP to reliably transfer email message from client to server,
port 25
direct transfer: sending server to receiving server
three phases of transfer
handshaking (greeting)
transfer of messages
closure
command/response interaction
commands: ASCII text
response: status code and phrase
messages must be in 7-bit ASCII
2: Application5 Layer
Scenario: Alice sends message to Bob
• 1) Alice uses UA to compose • 4) SMTP client sends Alice’s
message and “to” message over the TCP
bob@someschool.edu connection
• 2) Alice’s UA sends message • 5) Bob’s mail server places
to her mail server; message the message in Bob’s
placed in message queue mailbox
• 6) Bob invokes his user
• 3) Client side of SMTP
agent to read message
opens TCP connection with
Bob’s mail server
1 mail
mail
server user
user server
2 agent
agent 3 6
4
5
2: Application6 Layer
Sample SMTP interaction
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <alice@crepes.fr>
S: 250 alice@crepes.fr... Sender ok
C: RCPT TO: <bob@hamburger.edu>
S: 250 bob@hamburger.edu ... Recipient ok
C: DATA
S: 354 Enter mail, end with "." on a line by itself
C: Do you like ketchup?
C: How about pickles?
C: .
S: 250 Message accepted for delivery
C: QUIT
S: 221 hamburger.edu closing connection
2: Application Layer 7
Mail message format
From: alice@crepes.fr
MIME version To: bob@hamburger.edu
Subject: Picture of yummy crepe.
method used MIME-Version: 1.0
to encode data Content-Transfer-Encoding: base64
Content-Type: image/jpeg
multimedia data
type, subtype, base64 encoded data .....
.........................
parameter declaration ......base64 encoded data
encoded data
2: Application9 Layer
MIME
10
Mail access protocols
SMTP SMTP access
user
user protocol
agent
agent
12
POP3 protocol
S: +OK POP3 server ready
C: user bob
S: +OK
• authorization phase C: pass hungry
client commands: S: +OK user successfully logged on
user: declare username C: list
pass: password S: 1 498
server responses S: 2 912
+OK
S: .
C: retr 1
-ERR
S: <message 1 contents>
transaction phase, client: S: .
C: dele 1
list: list message numbers
C: retr 2
retr: retrieve message by S: <message 1 contents>
number S: .
dele: delete C: dele 2
quit C: quit
S: +OK POP3 server signing off
2: Application13Layer
POP3 (more) and IMAP
• More about POP3 • IMAP
Previous example uses Keep all messages in one
“download and delete” place: the server
mode. Allows user to organize
Bob cannot re-read e-mail if messages in folders
he changes client IMAP keeps user state
“Download-and-keep”: across sessions:
copies of messages on names of folders and
different clients mappings between
POP3 is stateless across message IDs and folder
sessions name
2: Application14Layer
SMTP, FTP and HTTP
• Connections: All have ASCII
– All use TCP command/response
– SMTP uses persistent interaction, status codes
connections HTTP: each object
encapsulated in its own
– FTP persistent control response msg
channel, non-persistent data FTP: one data channel per
channel per file. file
– HTTP uses both persistent SMTP: multiple objects sent
in multipart msg
and non-persistent channels
• Data Flow
– FTP and HTTP: pull (user
requests files)
– SMTP: push (email sent to
receiver without request,
result can be spam!)
15