0% found this document useful (0 votes)
46 views

Simple Mail Transfer Protocol: Waleed Bin Shahid

Uploaded by

Hasnain Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Simple Mail Transfer Protocol: Waleed Bin Shahid

Uploaded by

Hasnain Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

SMTP

Simple Mail Transfer Protocol

Waleed Bin Shahid


[email protected]
Background
• Electronic mail has been around since the beginning of the Internet.
It was the most popular application when the Internet was in its
infancy and has become more and more elaborate and powerful
over the years

• It remains one of the Internet’s most important and utilized


applications
Email Components
• User Agents
• Mail Reader
• Composing, editing, reading mail messages
• E.g. Outlook, Thunderbird, iPhone Mail Client, Web Browser
• Outgoing email messages stored on server
• Mail Servers
• Mailing Protocol: SMTP
• Retrieving Protocol: POP, IMAP, POP3
user
agent

mail user
server agent
SMTP mail user
server agent
SMTP
SMTP user
agent
mail
server
user
agent
user
agent
Mail Server
• A mail server is the computerized equivalent of your friendly
neighborhood mailman. Every email that is sent passes through a
series of mail servers along its way to its intended recipient

• Although it may seem like a message is sent instantly - zipping from


one PC to another in the blink of an eye - the reality is that a
complex series of transfers takes place

• Without this series of mail servers, you would only be able to send
emails to people whose email address domains matched your own -
i.e., you could only send messages from one example.com account
to another example.com account
Email Lifecycle (1)
• STEP: 1
• After composing a message and hitting send, Alice’s email client -
whether it's Outlook Express or Gmail - connects to her domain's
SMTP server. Let’s call it smtp.example.com

• STEP: 2
• Her email client communicates with the SMTP server, giving it her
address, Bob’s email address, the message body and any
attachments.

• STEP: 3
• The SMTP server processes Bob’s email address - especially its
domain. If the domain name is the same as Alice’s, the message is
routed directly over to the domain's POP3 or IMAP server - no
routing between servers is needed.
• If the domain is different, though, the SMTP server will have to
communicate with the other domain's server.
Email Lifecycle (2)
• STEP: 4
• In order to find the recipient's server, the sender's SMTP
server has to communicate with the DNS, or Domain Name
Server. The DNS takes the recipient's email domain name and
translates it into an IP address
• By knowing this information, an outgoing mail server can
perform its work more efficiently
Email Lifecycle (3)
• STEP: 5
• Client side of SMTP, running on Alice’s mail server, sees the
message in the message queue. It opens a TCP connection to
an SMTP server, running on Bob’s mail server
• After some initial SMTP handshaking, the SMTP client sends
Alice’s message into the TCP connection.

• STEP: 6
• Bob’s SMTP server scans the incoming message. If it
recognizes the domain and the user name, it forwards the
message along to the domain's POP3 or IMAP server. From
there, it is placed in a sendmail queue until the recipient's
email client allows it to be downloaded. At that point, the
message can be read by the recipient.
Email Lifecycle
More about SMTP
• SMTP has three phases of mail transfer
• Handshaking
• Transfer of Messages
• Closure

• It is important to observe that 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.

• 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

• In particular, 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
SMTP Handshaking
• Let’s now take a closer look at how SMTP transfers a message from a
sending mail server to a receiving mail server

• First, the client SMTP (running on the sending mail server host) has TCP
establish a connection to port 25 at the server SMTP (running on the
receiving mail server host). If the server is down, the client tries again later

• Once this connection is established, the server and client perform some
application-layer handshaking where SMTP clients and servers introduce
themselves before transferring information.

• During this SMTP handshaking phase, the SMTP client indicates the e-mail
address of the sender (the person who generated the message) and the e-
mail address of the recipient
..contd
• Once the SMTP client and server have introduced themselves to
each other, the client sends the message

• SMTP can count on the reliable data transfer service of TCP to get
the message to the server without errors

• The client then repeats this process over the same TCP connection if
it has other messages to send to the server; otherwise, it instructs
TCP to close the connection

• Commands are in ASCII text


• Response is a status code or a phrase
• Messages must be in 7-bit ASCII
SMTP Commands (1)
• HELO
It's the first SMTP command: is starts the conversation identifying the sender server and is
generally followed by its domain name

• EHLO
An alternative command to start the conversation, underlying that the server is using the
Extended SMTP protocol

• MAIL FROM
With this SMTP command the operations begin: the sender states the source email address
in the "From" field and actually starts the email transfer

• RCPT TO
It identifies the recipient of the email; if there are more than one, the command is simply
repeated address by address

• SIZE
This SMTP command informs the remote server about the estimated size (in terms of
bytes) of the attached email. It can also be used to report the maximum size of a message
to be accepted by the server
SMTP Commands (2)
• DATA
With the DATA command the email content begins to be transferred; it's
generally followed by a 354 reply code given by the server, giving the
permission to start the actual transmission

• VRFY
The server is asked to verify whether a particular email address or
username actually exists

• AUTH
With the AUTH command, the client authenticates itself to the server, giving
its username and password. It's another layer of security to guarantee a
proper transmission

• QUIT
It terminates the SMTP conversation.
Mail Access Protocols
POP
• Both POP (Post Office Protocol) and IMAP (Internet Message
access protocol) allow people to get access to their email from
a remote server

• POP simply downloads email to your computer, and usually


(but not always) deletes the email from the remote server

• What’s the biggest problem with POP?


• You have multiple devices for accessing email.
POP
• POP begins when the user agent (the client) opens a TCP connection
to the mail server (the server) on port 110

• With the TCP connection established, POP3 progresses through


three phases: authorization, transaction, and update

• Authorization: During the first phase, authorization, the user agent


sends a username and a password to authenticate the user

• Transaction: During the second phase, transaction, the user agent


retrieves messages; also during this phase, the user agent can mark
messages for deletion, remove deletion marks, and obtain mail
statistics

• Update: Update, occurs after the client has issued the quit
command, ending the POP3session; at this time, the mail server
deletes the messages that were marked for deletion
S: +OK POP3 server ready
C: user bob
Authorization Phase S: +OK
C: pass hungry
• client commands:
S: +OK user successfully logged on
• user: declare username
• pass: password C: list
S: 1 498
• server responses
S: .
• +OK 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
IMAP
• When you read an email message using IMAP, you aren't actually
downloading or storing it on your computer; instead, you are
reading it off of the server

• As a result, it's possible to check your email from several different


devices without missing a thing

• Another important feature of IMAP is that it has commands that


permit a user agent to obtain components of messages

• For example, a user agent can obtain just the message header of a
message or just one part of a multipart MIME message. This feature
is useful when there is a low-bandwidth connection
Web Based Email
• More and more users today are sending and accessing their e-mail
through their Web browsers

• With this service, the user agent is an ordinary Web browser, and
the user communicates with its remote mailbox via HTTP/S

• When a recipient, such as Bob, wants to access a message in his


mailbox, the e-mail message is sent from Bob’s mail server to Bob’s
browser using the HTTP protocol rather than the POP3 or IMAP
protocol

• When a sender, such as Alice, wants to send an e-mail message, the


e-mail message is sent from her browser to her mail server over
HTTP rather than over SMTP

• Alice’s mail server, however, still sends messages to, and receives
messages from, other mail servers using SMTP
SMTP vs. HTTP
• Similarities
• Both used for transferring files
• Both use persistent connections

• Differences
• HTTP is PULL Protocol; SMTP is PUSH protocol
• SMTP requires message body to be in 7-bit ASCII
format, HTTP has no such requirement
Mail Message Format
• Header: This contains information about the email’s origins, such
as the address it came from, how it reached it’s destination, and
who sent it.

• Body: Which contains the email message and/or file attachments


Sender

Recipient

Content
Gmail to Gmail
Yahoo to Gmail 2016
Yahoo to Gmail 2014
Yahoo to Gmail 2011
Outlook to Gmail 2016
Hotmail to Gmail 2012

You might also like