Electronic Mail (E-MAIL ARCH, MIME, SMTP, IMAP, POP3) PDF
Electronic Mail (E-MAIL ARCH, MIME, SMTP, IMAP, POP3) PDF
Electronic Mail (E-MAIL ARCH, MIME, SMTP, IMAP, POP3) PDF
• When both sender and receiver are connected to the mail server via a LAN
or a WAN, we need two UAs, two pairs of MTAs (client and server), and a
pair of MAAs (client and server). This is the most common situation today.
USER AGENT
• The first component of an electronic mail system is the user agent (UA).
• It provides service to the user to make the process of sending and receiving a message easier.
• Services Provided by a User Agent
• A user agent is a software package (program) that composes, reads, replies to, and forwards
messages. It also handles local mailboxes on the user computers.
• User Agent Types
• There are two types of user agents:
• command-driven and
• GUI-based.
• Command-driven user agents belong to the early days of electronic mail. They are still present as the
underlying user agents in servers.
• A command-driven user agent normally accepts a one character command from the keyboard to
perform its task.
• For example, a user can type the character r, at the command prompt, to reply to the sender of
the message, or type the character R to reply to the sender and all recipients.
• Modern user agents are GUI-based. They contain graphical user interface (GUI) components that
allow the user to interact with the software by using both the keyboard and the mouse. They have
graphical components such as icons, menu bars, and windows that make the services easy to access.
• Some examples of GUI-based user agents are Eudora, Outlook, and Netscape.
Sending Mail
• Message Format
• to distinguish the user interface • RFC 822 defines messages to have two parts: a header and
(i.e., your mail reader) from the a body. Both parts are represented in ASCII text.
underlying message transfer • Originally, the body was assumed to be simple text. This is
protocols (such SMTP or IMAP), still the case, although RFC 822 has been augmented by
and MIME to allow the message body to carry all sorts of data.
• (2) to distinguish between this • This data is still represented as ASCII text, but because it
may be an encoded version of, say, a JPEG image, it’s not
transfer protocol and a necessarily readable by human users
companion protocol (RFC 822
and MIME) that defines the
format of the messages being
exchanged.
• We start by looking at the
message format.
• The message header is a series of <CRLF>-terminated lines.
• (<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.) .
• The header is separated from the message body by a blank
line.
• Each header line contains a type and value separated by a
colon.
• Many of these header lines are familiar to users, since they
are asked to fill them out when they compose an email
message;
• for example, the To: header identifies the message
recipient, and the Subject: header says something about the
purpose of the message.
• Other headers are filled in by the underlying mail delivery
system.
• Examples include Date: (when the message was
transmitted), From: (what user sent the message), and
Received: (each mail server that handled this message).
• There are, of course, many other header lines; the
interested reader is referred to RFC 822.
Sending Mail
• To send mail, the user, through the UA,
creates mail that looks very similar to
postal mail.
• It has an envelope and a message
• Envelope
• The envelope usually contains the sender
address, the receiver address
• Message
• The message contains the header and the
body.
• The header of the message defines the
sender, the receiver, the subject of the
message, and some other information.
• The body of the message contains the
actual information to be read by the
recipient.
• Envelope
• The envelope usually contains the sender
address, the receiver address, and other
information.
• Message
• The message contains the header and the
body. The header of the message defines
the
• sender, the receiver, the subject of the
message, and some other information. The
body
• of the message contains the actual
information to be read by the recipient.
Receiving Mail • Local Part
• The user agent is triggered by the user (or a timer). If a user • The local part defines the name of a
has mail, the UA informs the user with a notice. If the user is
ready to read the mail, a list is displayed in which each line special file, called the user mailbox,
contains a summary of the information about a particular where all of the mail received for a user
message in the mailbox.
is stored for retrieval by the message
• The summary usually includes the sender mail address, the
subject, and the time the mail was sent or received. The access agent.
user can select any of the messages and display its contents
on the screen. • Domain Name
• Addresses • The second part of the address is the
• To deliver mail, a mail handling system must use an domain name. An organization usually
addressing system with unique addresses.
• In the Internet, the address consists of two parts: a local
selects one or more hosts to receive
part and a domain name, separated by an @ sign. and send e-mail; they are sometimes
called mail servers or exchangers.
• The domain name assigned to each
mail exchanger either comes from the
DNS database or is a logical name (for
example, the name of the
organization).
Mailing List or Group List
• The only difference is that a mail gateway typically buffers messages on disk and is willing to try retransmitting them to the
next machine for several days, while an IP router buffers datagrams in memory and is only willing to retry transmitting them
for a fraction of a second.
IMPORTANCE OF MAIL GATEWAYS
• 1.recipient does not want to include the • The only difference is that a mail
specific host on which he or she reads gateway typically buffers messages on
email in his or her address. disk and is willing to try retransmitting
• 2.Another is scale: In large organizations, them to the next machine for several
it’s often the case that a number of days, while an IP router buffers
different machines hold the mailboxes for datagrams in memory and is only willing
the organization. to retry transmitting them for a fraction
of a second.
• The forwarding gateway maintains a
database that maps users into the
machine on which their mailbox resides;
the sender need not be aware of this
specific name.
• 3. user’s mailbox may not always be up or
reachable, in which case the mail
gateway holds the message until it can be
delivered.
• Each SMTP session involves a dialog between the two mail daemons, with one
acting as the client and the other acting as the server.
• Multiple messages might be transferred between the two hosts during a single
session.
• SMTP is also ASCII based. This means it is possible for a human at a keyboard to
pretend to be an SMTP client program.
• SMTP is best understood by a simple example.
Commands and Responses
SMTP uses commands and responses to transfer
messages between an MTA client and an MTA server.
Commands
• Commands are sent from the client to the server. The
format of a command is shown below:
• Keyword: argument(s)
• Each command or reply is terminated by a two-
character (carriage return and line feed) end-of-line
token.
• It consists of a keyword followed by zero or more
arguments.
• SMTP defines 14 commands
• In each exchange, the client posts a command
(e.g.,HELO, MAIL, RCPT, DATA, QUIT) and
• the server responds with a code (e.g., 250, 550,
354, 221).
• The server also returns a human-readable
explanation for the code (e.g., No such user here).
• Responses
• Responses are sent from the server to the client.
• A response is a three-digit code that may be
followed by additional textual information.
Mail Transfer Phases
• The process of transferring a mail message occurs in three
phases:
• connection establishment,
• mail transfer, and
• connection termination.
• Connection Establishment
• After a client has made a TCP connection to the well-known
port 25, the SMTP server starts the connection phase
• This phase involves the following three steps,
• 1.The server sends code 220 (service ready) to tell the client
that it is ready to receive mail.
• If the server is not ready, it sends code 421 (service not
available).
• 2. The client sends the HELO message to identify itself using
its domain name address. This step is necessary to inform
the server of the domain name of the client. 3. The server
responds with code 250 (request command completed) or
some other code depending on the situation.
mail transfer
• After connection has been established between the SMTP client and
server, a single message between a sender and one or more
recipients can be exchanged. This phase involves eight steps. Steps 3
and 4 are repeated if there is more than one recipient
• 1. The client sends the MAIL FROM message to introduce the sender
of the message. It includes the mail address of the sender (mailbox
and the domain name). This step is needed to give the server the
return mail address for returning errors and reporting messages.
• 2. The server responds with code 250 or some other appropriate
code.
• 3. The client sends the RCPT TO (recipient) message, which includes
the mail address of the recipient.
• 4. The server responds with code 250 or some other appropriate
code.
• 5. The client sends the DATA message to initialize the message
transfer.
• 6. The server responds with code 354 (start mail input) or some other
appropriate message.
• 7. The client sends the contents of the message in consecutive lines.
Each line is terminated by a two-character end-of-line token (carriage
return and line feed).
• The message is terminated by a line containing just one period.
• 8. The server responds with code 250 (OK) or some other appropriate
code.
Connection Termination
• After the message is transferred
successfully, the client
terminates the connection. This
• phase involves two steps
• 1. The client sends the QUIT
command.
• 2. The server responds with code
221 or some other appropriate
code.
• After the connection termination
phase, the TCP connection must
be closed.
MESSAGE ACCESS AGENT: POP AND IMAP
(or)
access protocol
(or)
Mail Reader
• Mail Reader • The first and the second stages of mail
• The final step is for the user to actually retrieve his or her delivery use SMTP.
messages from the mailbox, read them, reply to them,
and possibly save a copy for future reference. • However, SMTP is not involved in the
• The user performs all these actions by interacting with a
third stage because SMTP is a push
mail reader. protocol; it pushes the message from the
client to the server. In other words, the
retrieve his or her direction of the bulk data (messages) is
messages from the from the client to the server.
USER
mailbox, read them,
MAIL READER
• the third stage needs a pull protocol; the
reply to them, and client must pull messages from the
possibly save a copy server. The direction of the bulk data are
for future reference from the server to the client.
• The third stage uses a message access
agent.
• Currently two message access protocols
are available:
• Post Office Protocol, version 3(POP3) and
• Internet Mail Access Protocol, version 4
(IMAP4).
IMAP
• IMAP is similar to SMTP in many ways.
• It is a client/server protocol running over TCP, where the client issues
commands in the form of <CRLF>-terminated ASCII text lines and the
mail server responds in kind.
• The exchange begins with the client authenticating him- or herself
and identifying the mailbox he or she wants to access.
IMAP state transition diagram.
• In this diagram,
• LOGIN, AUTHENTICATE, SELECT, EXAMINE, CLOSE, and LOGOUT are example commands that the
client can issue.
• Other common commands include FETCH, STORE, DELETE, and EXPUNGE.
• OK is one possible server response.
Additional server responses include:
NO (client does not have permission to perform that operation) and
BAD (command is ill formed).
• When the user asks to FETCH a message, the server returns it in MIME format and the mail
reader decodes it.
• IMAP also defines a set of message attributes.
• attributes exchanged as part of other commands, independent of transferring the message
itself.
• Message attributes include information like
• the size of the message and,
• various flags associated with the message (e.g., Seen, Answered, Deleted, and Recent).
• These flags are used to keep the client and server synchronized; that is,
• when the user deletes a message in the mail reader, the client needs to report this fact to the
mail server. Later, the user decide to expunge(completely remove) all deleted messages, the
client issues an EXPUNGE command to the server, which knows to actually remove all earlier
deleted messages from the mailbox.
• Finally, when the user replies to a message, or sends a new message, the mail reader does not
forward the message from the client to the mail server using IMAP, but it instead uses SMTP.
This means that the user’s mail server is effectively the first mail gateway traversed along the
path from the desktop to the recipient’s mailbox.
Functions of IMAP4
A user can check the e-mail header prior to downloading.
• A user can search the contents of the e-mail for a specific string of
characters prior to downloading.
• A user can partially download e-mail. This is especially useful if
bandwidth is limited and the e-mail contains multimedia with high
bandwidth requirements.
• A user can create, delete, or rename mailboxes on the mail server.
• A user can create a hierarchy of mailboxes in a folder for e-mail
storage.
Post Office Protocol, version 3 (POP3)
• POP3 is simple and limited in
functionality.
• The client POP3 software is installed on
the recipient computer;
• the server POP3 software is installed on
the mail server.
• Mail access starts with the client when
the user needs to download its e-mail
from the mailbox on the mail server.
• The client opens a connection to the
server on TCP port 110.
• It then sends its user name and password
to access the mailbox.
• The user can then list and retrieve the
mail messages, one by one. Figure shows
an example of downloading using POP3.
POP3 has two modes:
• delete mode • Keep mode
• the mail is deleted from the mailbox • the mail remains in the mailbox after
after each retrieval. retrieval.
• normally used when the user is • normally used when the user
working at her permanent computer accesses her mail away from her
and can save and organize the primary computer (e.g., a laptop).
received mail after reading or replying. • The mail is read but kept in the
system for later retrieval and
organizing.
Disadvantages of POP3:
• It does not allow the user to organize the mail on the server;
• the user cannot have different folders on the server. (Of course, the
user can create folders on their own computer.)
• In addition, POP3 does not allow the user to partially check the
contents of the mail before downloading.