NETWORK STRATEGIES LECTURE 8 SIMPLE MAIL TRANSFER PROTOCOL

  • Slides: 34
Download presentation
NETWORK STRATEGIES LECTURE 8 SIMPLE MAIL TRANSFER PROTOCOL (SMTP) Dr. Naveed Ahmad Assistant Professor

NETWORK STRATEGIES LECTURE 8 SIMPLE MAIL TRANSFER PROTOCOL (SMTP) Dr. Naveed Ahmad Assistant Professor Department of Computer Science University of Peshawar

What is SMTP? � � It’s the backbone of email Text based protocol developed

What is SMTP? � � It’s the backbone of email Text based protocol developed by Jonathan B. Postel August 1982 The purpose of SMTP is to transfer mail reliably and efficiently Still being used in email servers today

User Agent (UA) � The first component of an electronic mail system is the

User Agent (UA) � 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. E. g. command line are mail, pine, elm and GUI are Outlook, Opera.

Message Transfer Agent (MTA) � The actual mail transfer is done through message transfer

Message Transfer Agent (MTA) � The actual mail transfer is done through message transfer agents (MTAs). To send mail, a system must have the client MTA, and to receive mail, a system must have a server MTA. Two pairs of MTA client-server programs are used in the most common situation.

Message Access Agent (MAA) � The first and the second stages of mail delivery

Message Access Agent (MAA) � The first and the second stages of mail delivery use SMTP. However, SMTP is not involved in the third stage because SMTP is a push protocol; it pushes the message from the client to the server. In other words, the direction of the bulk data (messages) is from the client to the server. On the other hand, the third stage needs a pull protocol; the client must pull messages from the server. The direction of the bulk data are from the server to the client. The third stage uses a message access agent.

Email format

Email format

Electronic Mail outgoing message queue user mailbox � user agent Three major components: user

Electronic Mail outgoing message queue user mailbox � user agent Three major components: user agents mail servers mail server user agent SMTP simple mail transfer protocol: mail server SMTP User Agent a. k. a. “mail reader” composing, editing, reading mail SMTP user agent mail server messages user agent e. g. , Eudora, Outlook, elm, Mozilla Thunderbird outgoing, incoming messages stored on server user agent

Electronic Mail: mail servers Mail Servers mailbox contains incoming messages for user message queue

Electronic Mail: mail servers Mail Servers mailbox contains incoming messages for user message queue of outgoing (to be sent) mail messages SMTP protocol between mail servers to send email messages client: sending mail server “server”: receiving mail server user agent � mail server user agent SMTP mail server SMTP user agent mail server user agent

Scenario: Alice sends message to Bob � � � 1) Alice uses UA to

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

Case-1 When the sender and the receiver of an e-mail are on the same

Case-1 When the sender and the receiver of an e-mail are on the same mail server, we need only two user agents.

Case-2 When the sender and the receiver of an e-mail are on different mail

Case-2 When the sender and the receiver of an e-mail are on different mail servers, we need two UAs and a pair of MTAs (client and server).

Case-3 When the sender is connected to the mail server via a LAN or

Case-3 When the sender is connected to the mail server via a LAN or a WAN, we need two UAs and two pairs of MTAs (client and server).

Case-4 When both sender and receiver are connected to the mail server via a

Case-4 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.

Push and Pull Messages

Push and Pull Messages

Connection phases: SMTP [RFC 2821] uses TCP to reliably transfer email message from client

Connection phases: 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 handshaking (greeting) transfer of messages closure command/response interaction commands: ASCII text response: status code and phrase messages must be in 7 -bit ASCII

Responses Table

Responses Table

Connection establishment

Connection establishment

Messages Transfer

Messages Transfer

Connection Termination

Connection Termination

Commands of SMTP HELO MAIL FROM RCPT TO DATA QUIT RSET VRFY EXPN HELP

Commands of SMTP HELO MAIL FROM RCPT TO DATA QUIT RSET VRFY EXPN HELP NOOP : Request to initiate SMTP session : Sender’s E-Mail address : Receiver’s E-Mail address : Body of message : Terminates SMTP connection : Aborts mail transaction : Asks receiver to verify the validity of the mailbox : Asks receiver to identify mailing list : Causes receiver to send help information : Forces server to verify the communication with SMTP receiver

Session Establishment and Termination

Session Establishment and Termination

SMTP Mail Transaction Process 1. Transaction Initiation and Sender Identification S: HELO sjsu. edu

SMTP Mail Transaction Process 1. Transaction Initiation and Sender Identification S: HELO sjsu. edu R: 250 Hello sjsu. edu S: MAIL FROM: <cooldd 10@yahoo. com> R: 250 Ok 2. Recipient Identification S: RCPT TO: <jainip_1983@gmail. com> R: 250 Ok 3. Mail Transfer S: DATA R: 354 End data with <CR><LF> S: <The message data> S: . R: 250 Ok, message accepted for delivery: queued as 12345 S: QUIT R: 221 Bye

Status Codes The Server responds with a three digit code that may be followed

Status Codes The Server responds with a three digit code that may be followed by the text info. � 2 XX – The SMTP server has accepted the command has completed the request. � 3 XX - Command is accepted and more information follows. � 4 XX - Try again later as there was a temporary failure with the command or the server. � 5 XX – The requested operation will never be completed due to permanent error.

� � � MIME Multi-purpose Internet Mail Extension A protocol for transmitting non-text information

� � � MIME Multi-purpose Internet Mail Extension A protocol for transmitting non-text information across the Internet. Basically, non-ASCII data is converted to ASCII for transmission and then converted back at the receiver. A specification for automatically sending objects other than text in email messages. MIME is usually associated with multimedia, such as images, audio recordings, and movies. Additional hardware and helper software usually required. Common MIME-compliant mailers: � pine, metamail, Netscape messenger, MS Outlook

MIME

MIME

Push vs Pull

Push vs Pull

Email on Internet

Email on Internet

Mail access protocols SMTP user agent sender’s mail server receiver’s mail server SMTP: delivery/storage

Mail access protocols SMTP user agent sender’s mail server receiver’s mail server SMTP: delivery/storage to receiver’s server Mail access protocol: retrieval from server access protocol POP: Post Office Protocol [RFC 1939] • authorization (agent <-->server) and download IMAP: Internet Mail Access Protocol [RFC 1730] • more features (more complex) • manipulation of stored msgs on server HTTP: gmail, Hotmail, Yahoo! Mail, etc. user agent

POP � � Short for Post Office Protocol, a protocol used to retrieve e-mail

POP � � Short for Post Office Protocol, a protocol used to retrieve e-mail from a mail server. Most e-mail applications (sometimes called an e-mail client) use the POP protocol, although some can use the newer IMAP (Internet Message Access Protocol). There are two versions of POP. The first, called POP 2, became a standard in the mid-80's and requires SMTP to send messages. The newer version, POP 3, can be used with or without SMTP. POP 3 uses TCP/IP port 110.

Post Office Protocol (POP 3)

Post Office Protocol (POP 3)

POP 3 protocol S: +OK POP 3 server ready • authorization phase client commands:

POP 3 protocol S: +OK POP 3 server ready • authorization phase client commands: user: declare username pass: password server responses +OK -ERR transaction phase, client: list: list message numbers retr: retrieve message by number dele: delete quit C: user bob S: +OK C: pass hungry S: +OK user successfully logged on C: list S: 1 498 S: 2 912 S: . C: retr 1 S: <message 1 contents> S: . C: dele 1 C: retr 2 S: <message 1 contents> S: . C: dele 2 C: quit S: +OK POP 3 server signing off

IMAP is an Internet Message Access Protocol. It is a method of accessing electronic

IMAP is an Internet Message Access Protocol. It is a method of accessing electronic mail messages that are kept on a possibly shared mail server. In other words, it permits a "client" email program to access remote message stores as if they were local. For example, email stored on an IMAP server can be manipulated from a desktop computer at home, a workstation at the office, and a notebook computer while travelling, without the need to transfer messages or files back and forth between these computers. IMAP uses TCP/IP port 143.

POP 3 vs IMAP � � � With IMAP, all your mail stays on

POP 3 vs IMAP � � � With IMAP, all your mail stays on the server in multiple folders, some of which you have created. This enables you to connect to any computer and see all your mail and mail folders. In general, IMAP is great if you have a dedicated connection to the Internet or you like to check your mail from various locations. With POP 3 you only have one folder, the Inbox folder. When you open your mailbox, new mail is moved from the host server and saved on your computer. If you want to be able to see your old mail messages, you have to go back to the computer where you last opened your mail. With POP 3 "leave mail on server" only your email messages are on the server, but with IMAP your email folders are also on the server.

POP vs IMAP � POP: - offers one-way downloading of your messages from the

POP vs IMAP � POP: - offers one-way downloading of your messages from the Gmail servers to your computer - always downloads the entire message, making it easy to back-up your mail - only downloads your messages -- not your labels - good for people who don't want to leave mail on Gmail's servers, or don't want two-way synchronization IMAP: - offers two-way syncing between Gmail and mail client actions. If you read a message in your email client, it will be marked read on the web! - save space by downloading only the message headers, or download whole messages to work offline - your labels appear as folders, and vice versa -- so it's easy to stay organized - provides access to Gmail's Drafts, Sent Mail and Spam folders - great if you check your mail from multiple computers or mobile devices -- you'll see the same messages and folders, no matter what email client you're using - a flexible, more reliable, more complete access choice