Email
• MIME
• SMTP
• POP
• IMAP
Main components: User agents, message access agent, and
transfer agents
Components of email
User agent: used to compose mail, read mail, store in local
computer (if two users are on the same LAN, we only need two
user agents). Eg. Eudora, Outlook, Netscape.
MTAs (message transfer agents) to transfer from local machine
to a server, server to another server and so on. SMTP
Message Access agent – to retrieve from the local server to the
local recipient computer. Pop and IMAP, MIME
Mime (multipurpose internet mail extenstion)
• Allows non-ASCII characters. Used for all languages, video,
and audio.
Figure 20.9 MIME
Figure 20.10 MIME header
Table 20.1 Data types and subtypes in MIME
Table 20.1 Data types and subtypes in MIME (Continued)
Table 20.2 Content-transfer-encoding
SMTP (simple mail transfer protocol)
• Uses commands and responses to transfer messages. Each
command or reply is terminated by carriage return and linefeed.
20.3 MESSAGE TRANSFER AGENT:
SMTP
The actual mail transfer requires message transfer agents (MTAs). The
protocol that defines the MTA client and server in the Internet is called
Simple Mail Transfer Protocol (SMTP).
The topics discussed in this section include:
Commands and Responses
Mail Transfer Phases
Figure 20.13 SMTP range
Figure 20.14 Commands and responses
Figure 20.15 Command format
Table 20.4 Commands
Table 20.5 Responses
Table 20.5 Responses (Continued)
Figure 20.16 Connection establishment
Figure 20.17 Message transfer
Figure 20.18 Connection termination
CS 352
Simple Mail Transfer Protocol
CS 352, Lecture 5.1
http://www.cs.rutgers.edu/~sn624/352
Srinivas Narayana
20
We’re all familiar with email.
How does it work?
outgoing
Electronic Mail message queue
user mailbox
user
Three major components: agent
1. User agents mail
user
server
• a.k.a. “mail reader” agent
SMTP mail
• e.g., Applemail, Outlook server user
SMTP agent
• Web-based user agents (ex: gmail)
SMTP
mail user
server agent
user
agent
user
agent
22
Electronic Mail: Mail servers
2. Mail Servers user
agent
• Mailbox contains incoming messages
for user mail
user
server
• Message queue of outgoing (to be sent) agent
mail messages SMTP mail
• Sender mail server makes connection server user
to Receiver mail server agent
• IP address, port 25 SMTP
SMTP
3. SMTP protocol mail user
• Used to send messages server agent
• Client: sending user agent or sending
mail server user
agent
• server: receiving mail server user
agent
23
Scenario: Alice sends message to Bob
1) Alice 4) SMTP client sends Alice’s
(alice@rutgers.edu) uses message over the TCP
UA to compose message to connection
bob@nyu.edu
5) Bob’s mail server places the
2) Alice’s UA sends message to message in Bob’s incoming
her mail server; message mailbox
placed in outgoing message 6) Sometime later, Bob invokes
queue his user agent to read
3) Client side of SMTP opens message
TCP connection with Bob’s
mail server
1 mail
mail
server user
user server
Alice 2 agent Bob
agent 3 6
4 5
Rutgers mail server NYU mail server 24
Observations on these exchanges
• Mail servers are useful “always on” endpoints
• Receiving the email on behalf of Bob, should Bob’s machine be turned off
• Retrying the delivery of the email to Bob on behalf of Alice, should Bob’s
mail server be unavailable in the first attempt
• The same machine can act as client and server based on context
• Rutgers’s mail server is the server when Alice sends the mail
• It is the client when it sends mail to Bob’s mail server
• SMTP is push-heavy: info is pushed from client to server
• Contrast to HTTP or DNS where info is pulled from the server
Sample SMTP interaction
• A small demo
Sample SMTP interaction
220 hill.com SMTP service ready
HELO town.com
250 hill.com Hello town.com, pleased to meet you
MAIL FROM: <jack@town.com>
250 <jack@town.com>… Sender ok
RCPT TO: <jill@hill.com>
250 <jill@hill.com>… Recipient ok
DATA
354 Enter mail, end with “.” on a line by itself
Jill, I’m not feeling up to hiking today. Will you please fetch me a pail of water?
.
250 message accepted
QUIT
221 hill.com closing connection
27
MAIL command response codes
220: Service ready
250: Request command complete
354: Start mail input
421: Service not available
28
Mail message (stored on server) format
SMTP: protocol for exchanging email msgs
header
RFC 822: standard for text message format: blank
line
• header lines, e.g.,
• To: body
• From:
• Subject:
different from SMTP commands!
(these would still be under “DATA”)
• body
• the “message”, ASCII characters only
29
Message format: multimedia extensions
• MIME: multimedia mail extension, RFC 2045, 2056
• additional lines in msg header declare MIME content type
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
30
CS 352
Mail: Access Protocols
CS 352, Lecture 5.2
http://www.cs.rutgers.edu/~sn624/352
Srinivas Narayana
31
Mail access protocols
POP3 or IMAP4
SMTP SMTP access user
user Bob
Alice protocol agent
agent
sender’s mail receiver’s mail
server server
• SMTP: delivery/storage to receiver’s server
• Mail access protocol: retrieval from server
• POP: Post Office Protocol [RFC 1939]
• Client connects to POP3 server on TCP port 110
• IMAP: Internet Mail Access Protocol [RFC 1730]
• Client connects to TCP port 143
• HTTP: gmail, outlook, etc.
32
POP vs IMAP
• POP3 • IMAP4
• Stateless server • Stateful server
• UA-heavy processing • UA and server processing
• UA retrieves email from • Server sees folders, etc.
server, then typically deleted which are visible to UAs
from server • Changes visible at the server
• Latest changes are at the UA • Complex protocol
• Simple protocol (list, retr, del
within a POP session)
33
What about web-based email?
• Connect to mail servers via web browser
• Ex: gmail, outlook, etc.
• Browsers speak HTTP
• Email servers speak SMTP
• Need a bridge to retrieve email using HTTP
34
Web based email
HTTP HTTP
HTTP server HTTP
server
SMTP SMTP
Client server
Internet
35
Comparing SMTP with HTTP
• HTTP: pull
• SMTP: push
• both have ASCII command/response interaction, status codes
• HTTP: each object encapsulated in its own response msg
• SMTP: multiple objects sent in multipart msg
• HTTP: can put non-ASCII data directly in response
• SMTP: need ASCII-based encoding
36
Mail Transfer Agents
MTAs do the actual mail transfers
MTAs are not meant to be directly accessed by users.
MMDF
SENDMAIL
Mail Access Protocols
The MTAs place the email in the user’s mailbox
The Mail Access Protocols are used by the users to
retrieve the email from the mailbox
POP3
IMAP4
POP3 and IMAP4
• Message access protocols. (pull)
• Post Office protocol. Simple with limited functionality. Uses
port 100. Has to modes, delete or keep.
• Internet Mail Access Protocol is used to check mail directly from
the web.
20.4 MESSAGE ACCESS AGENT:
POP AND IMAP
The third stage of mail delivery uses a message access agent; the client
must pull messages from the server. Currently two message access
protocols are available: Post Office Protocol, version 3 (POP3) and
Internet Mail Access Protocol, version 4.
The topics discussed in this section include:
POP3
IMAP4
Figure 20.19 POP3 and IMAP4
Post Office Protocol v3
Simple
Allows the user to obtain a list of their Emails
Users can retrieve their emails
Users can either delete or keep the email on their
system
Minimizes server resources
Figure 20.20 POP3
How does POP work?
Incoming messages are stored at a POP server until the user logs in
using an email client and downloads the messages to their computer.
After user downloads the message, it is deleted from the server.
Adv:
POP does not require an internet connection for accessing the
downloaded mails.
Disadv:
For receiving e-mails only on one single device, POP is useful. It is not
possible to access the same email account from multi devices and
have actions synchronize between them.
Common Clients
• Eudora
• Gmail
• Outlook Express
• Mozilla Thunderbird
• Netscape
• Internet Explorer
POP vs. IMAP
POP3:
All Messages
IMAP:
Dr.Amer
Friends
….
Internet Mail Access Protocol v4
Has more features then POP3
User can check the email header before downloading
Emails can be accessed from any location
Can search the email for a specific string of characters before
downloading
User can download parts of an email
User can create, delete, or rename mailboxes on a server