Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Computer and

Communication Networks
EE-357 -TE-54
By Dr Mir Yasir Umair
Assistant Professor, MCS, NUST
Application Layer
Lecture 02
Electronic Mail
E-Mail

Application Layer
Electronic mail
• E-mail is an asynchronous communication medium - people send
and read messages when it is convenient for them, without having
to coordinate with other people’s schedules.

• Accessing mail
o Webmail – web interface e.g. Google, Hotmail etc
o Email Client – program installed on user’s
PC e.g. Outlook
Electronic mail outgoing
message queue
user mailbox
Three major user
components: agent

• user agents mail user


• mail servers server agent
• simple mail transfer SMTP
protocol: SMTP mail user
server agent

User Agent SMTP


• a.k.a. “mail reader” SMTP user
agent
• composing, editing, mail
reading mail messages server
user
• e.g., Outlook, Thunderbird, agent
iPhone mail client
user
• outgoing, incoming agent
messages stored on server
Application Layer
Electronic mail: mail servers
mail servers: user
agent
• mailbox contains
incoming messages for mail
user server
user
agent
• message queue of
outgoing (to be sent) SMTP mail user
mail messages server agent
• SMTP protocol between SMTP
mail servers to send
email messages SMTP user
o client: sending mail mail
agent
server server
user
o “server”: receiving agent
mail server
user
agent

Application 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
o handshaking (greeting)
o transfer of messages
o closure
• command/response interaction (like HTTP,
FTP)
o commands: ASCII text
o response: status code and phrase
• messages must be in 7-bit ASCI

Application Layer
Scenario: Alice sends message to Bob
1) Alice uses UA to compose 4) SMTP client sends
message “to” Alice’s message over
bob@someschool.edu
the TCP connection
2) Alice’s UA sends
message to her mail 5) Bob’s mail server
server; message placed in places the message in
message queue Bob’s mailbox
3) client side of SMTP opens 6) Bob invokes his user
TCP connection with
Bob’s mail server agent to read message

1 user mail user


mail agent
agent server server
2 3 6
4
5
Alice’s mail server Bob’s mail server
Application Layer
SMTP
• SMTP does not normally use intermediate mail servers for
sending mail, even when the two mail servers are located at
opposite ends of the world.
• E.g., If Alice’s server is in Hong Kong and Bob’s server is in St.
Louis, the TCP connection is a direct connection between the
Hong Kong and St. Louis servers.
• If Bob’s mail server is down, the message remains in Alice’s mail
server and waits for a new attempt—the message does not get
placed in some intermediate mail server.
Mail message format
SMTP: protocol for
exchanging email msgs header
blank
RFC 822: standard for text
line
message format:
• header lines, e.g.,
o To:
body
o From:
o Subject:
different from SMTP
MAIL FROM, RCPT TO:
commands!
• Body: the “message”
o ASCII characters only

Application Layer
SMTP VS HTTP
Comparators HTTP SMTP
Connection Persistent/ Non- Persistent
Persistent

Data Direction Pull Push


TCP is initiated by the is initiated by the
connection machine that wants to machine that wants to
receive the file send the file
Encapsulation One object per response multiple objects/
response

Port # 80 25
Mail access protocols
user
mail access user
SMTP SMTP protocol
agent agent
(e.g., POP,
IMAP)

sender’s mail receiver’s mail


server server

• SMTP: delivery/storage to receiver’s server


• mail access protocol: retrieval from server
o POP: Post Office Protocol [RFC 1939]: authorization,
download – BEST FOR SINGLE DEVICE USAGE
o IMAP: Internet Mail Access Protocol [RFC 1730]: more
features, including manipulation of stored msgs on server
– MOST APPLICABLE FOR MULTIPLE DEVICES LOGINS
o HTTP: gmail, Hotmail, Yahoo! Mail, etc > WEB BASED UA

Application Layer
In a Nutshell
Application Layer
POP3
• In this protocol the folder structure is not in sync with other devices.
• It downloads emails only from the Inbox folder.
• It is good only if you want to retrieve an email from only one device.
• One of the advantage of POP3 protocol is that you can view your email even when
there is no internet connection.
• It helps in saving the storage space on the mail server.

Application Layer
POP 3
Disadvantage of using POP3:
• A backup plan is needed for your emails in case your device crashes or if its lost.
• Your device is unsafe to viruses as the emails are fully downloaded.

Application Layer
POP3 protocol
S: +OK POP3 server ready
C: user bob
authorization phase S: +OK
C: pass hungry
• client commands: S: +OK user successfully logged on
o user: declare username
o pass: password C: list
S: 1 498
• server responses
S: 2 912
o +OK S: .
o -ERR C: retr 1
transaction phase, S: <message 1 contents>
S: .
client:
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
Application Layer
IMAP
• It is good for retrieving your email from multiple devices.
• All the emails are stored on the mail server so that you can retrieve them from any of
your devices.
• Also as the devices are synchronized you can view the emails in sent items, drafts,
deleted items and also emails in any custom folder.

Disadvantage of using IMAP :


• You cannot view an email without an internet connection.
• It creates local copies of the email on your device instead of downloading the item

Application Layer

You might also like