E-Mail
One of the most popular internet services is E-
mail.
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Common Architecture
The following shows components of e-mail system involved in Alice sending a
message to Bob.
TCP/IP Protocol Suite 2
Components of an email system
1. User Agent (UA)
2. Message
3. Message Transfer Agent(MTA)
4. Message Access Agent (MAA)
TCP/IP Protocol Suite 3
User Agent
• A user agent (UA) is a software package that is either
command (eg. pine, elm) or GUI based (eg.Microsoft Outlook,
Netscape). It facilitates:
o Composing messages -UA helps to compose messages by
providing a template that comes with a built-in editor.
o Reading messages -UA checks mail in the incoming box and
apart from message provides information such as sender,
size, subject and flag (read, new).
o Replying to messages- UA allows user to reply (send message)
back to sender
o Forwarding messages- UA facilitates forwarding message to a
third party.
o Handling mailboxes -UA creates two mailboxes for each user,
namely inbox (to store received emails) and outbox (to keep
TCP/IP Protocol Suite 4
all sent mails).
Message Format
• RFC822 defines message to have two parts namely header and a body.
• The message header is a series of <CRLF> (<CRLF>stands for carriage-return+line-feed,
which are a pair of ASCII control characters often used to indicate the end of a line of
text.)terminated lines.
• Each header line contains a type and value separated by a colon (:). It is filled by the
user/system. Some of them are:
o From user who sent the message
o To identifies the message recipient(s).
o Subject says something about the purpose of the message
o Date when the message was transmitted
o E-mail address consists of user_name@domain_name where domain_name is
hostname of the mail server.
The body of the message contains the actual information.
o The header is separated from the message body by a blank line.
• Initially email system was designed to send messages only in NVT 7-bit ASCII format.
o Languages such as French, German, Chinese, Japanese were not supported.
o Image, audio and video files cannot be sent.
TCP/IP Protocol Suite 5
Format of an email
TCP/IP Protocol Suite 6
E-mail address
TCP/IP Protocol Suite 7
• For example, a message containing plain text and an image file looks like:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="-------417CA6E2DE4ABCAFBC5"
From: Alice Smith <Alice@cisco.com>
To: Bob@cs.Princeton.edu
Subject: promised material
Date: Mon, 07 Sep 1998 19:45:19 -0400
---------417CA6E2DE4ABCAFBC5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
---------417CA6E2DE4ABCAFBC5
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
TCP/IP Protocol Suite 8
Message Transfer Agent (MTA): SMTP
• Message Transfer Agent (MTA) is a mail daemon (a version of send mail
program) that helps to transmit/receive message over the network.
• To send mail a system must have the client MTA, and to receive mail a
system must have a server MTA.
• Simple Mail Transfer Protocol (SMTP) defines communication between
client/serverMTA.
• SMTP defines how commands and responses must be sent back and forth.
TCP/IP Protocol Suite 9
SMTP range
TCP/IP Protocol Suite 10
Commands and responses
TCP/IP Protocol Suite 11
TCP/IP Protocol Suite 12
TCP/IP Protocol Suite 13
Connection establishment
220 service ready 1
2 HELO: deanza.edu
250 OK 3
TCP/IP Protocol Suite 14
Message transfer
TCP/IP Protocol Suite 15
Connection termination
1 QUIT
221 service closed 2
TCP/IP Protocol Suite 16
Message Access Agent (MAA)/Mail Reader: POP and IMAP
1. MAA or mail reader allows user to retrieve messages from the
mailbox, so that user can perform actions such as reply,
forwarding, etc.
2. The two message access protocols are:
o Post Office Protocol, version 3 (POP3)
o Internet Mail Access Protocol, version 4 (IMAP4)
3. SMTP is a push type protocol whereas POP3 and IMAP4 are
pop type protocol.
TCP/IP Protocol Suite 17
POP3
1. POP3 is simple and limited in functionality.
2. POP3 client is installed on the recipient computer and POP3 server
on the mail server.
3. The client opens a connection to the server on TCP port 110.
4. The client sends username and password to access the mailbox and
retrieve the messages.
5. POP3 works in two modes namely, delete and keep mode.
o In delete mode, mail is deleted from the mailbox after retrieval
o In keep mode, mail after reading is kept in mailbox for later retrieval.
Downloading message using POP3 is shown below:
TCP/IP Protocol Suite 18
Pop3
TCP/IP Protocol Suite 19
Pop3 and IMAP4
TCP/IP Protocol Suite 20
IMAP4
1. IMAP is a client/server protocol running over TCP. The client
issues commands and the mail server responds.
o The client can issue commands such as LOGIN, AUTHENTICATE,
SELECT,
EXAMINE CLOSE, LOGOUT, etc.
o Server responses include OK, FETCH, STORE, DELETE,
EXPUNGE, NO, BAD, etc.
2. The exchange begins with the client authenticating itself to
access the mailbox. This is represented as a state transition
diagram as shown below.
TCP/IP Protocol Suite 21
Multipurpose Internet Mail Extensions (MIME)
• MIME is a supplementary protocol that allows non-ASCII data to be sent
through e-mail.
• MIME transforms non-ASCII data to NVT ASCII and delivers to client MTA.
• The NVT ASCII data is converted back to non-ASCII form at the recipient
mail server.
• MIME defines five headers. They are:
o MIME-Version specifies the current version 1.1
o Content-Type specifies message type such as text (plain, html), image (jpeg,
gif), audio, video and application (postscript, msword). If more than one type
exists, then it is termed as multipart (mixed).
o Content-Transfer-Encoding defines how data in the message body is
encoded such as binary, base64, 7-bit, etc.
o Content-Id unique identifier the whole message in a multiple message type.
o Content-Description describes type of the message body.
TCP/IP Protocol Suite 22
MIME
TCP/IP Protocol Suite 23
MIME header
TCP/IP Protocol Suite 24
TCP/IP Protocol Suite 25
TCP/IP Protocol Suite 26
23-6 WEB-BASED MAIL
E-mail is such a common application that some
websites today provide this service to anyone who
accesses the site. Three common sites are Hotmail,
Yahoo, and Google. The idea is very simple. Let us go
through two cases:
TCP/IP Protocol Suite 27
Figure 23.19 Web-based e-mail, case 1
1
HTTP
transactions
3
2 4
TCP/IP Protocol Suite 28
Figure 23.20 Web-based e-mail, case 2
HTTP HTTP
transactions transactions
1 2 3
TCP/IP Protocol Suite 29
HTTP
Explain HTTP protocol in detail.
• WWW is a distributed client/server service, in which a client (web
browser) can access a service through a server, where the service is
distributed over many locations called sites.
• Both the client and server use Hypertext Transfer Protocol (HTTP).
• Web browsers allow users to access files (repository of information)
through uniform resource locator (URL).
• When user enters URL in the web browser, the browser forms a request
message and sends to the server.
• The server retrieves the requested URL and sends it as a response
message.
• The browser displays the response in HTML / appropriate format.
• HTTP uses one TCP connection on well known port 80 to transfer data
between client and the server.
TCP/IP Protocol Suite 30
• HTTP is a stateless request/response protocol
as shown.
TCP/IP Protocol Suite 31
The general form of message is shown below:
START_LINE <CRLF>
MESSAGE_HEADER <CRLF>
<CRLF>
MESSAGE_BODY <CRLF>
Request Message
TCP/IP Protocol Suite 32
Request line
• The request line specifies three elements:
• HTTP version specifies current version of the
protocol i.e., 1.1
• URL specifies path (absolute/relative) along with
document name.
• The Request type specifies methods that operate
on the URL are:
TCP/IP Protocol Suite 33
For example, the request line to retrieve file index.html on host cs.princeton.edu is
GET http://www.cs.princeton.edu/index.html HTTP/1.1
TCP/IP Protocol Suite 34
Request Header
• Request Header specifies client's configuration and preferred document
format:
TCP/IP Protocol Suite 35
The above example using request header is specified as
GET index.html HTTP/1.1
Host: www.cs.princeton.edu
Response Messages
TCP/IP Protocol Suite 36
Status line
• The status code field consists of three digits
(1xx-Informational, 2xx-Success, 3xx-
• Redirection, 4xx-Client Error, 5xx-Server Error)
• The status phrase explains the status code in
text form. Some of them are:
TCP/IP Protocol Suite 37
TCP/IP Protocol Suite 38
For example, the server reports as follows, if the requested file is not found
HTTP/1.1 404 Not Found
TCP/IP Protocol Suite 39
Response Header
The response for a moved page is given below.
HTTP/1.1 301 Moved Permanently
Location: http://www.princeton.edu/cs/index.html.
TCP/IP Protocol Suite 40