Email SMTP - Simple Mail Transfer Protocol RFC 821 POP - Post - - PowerPoint PPT Presentation

email
SMART_READER_LITE
LIVE PREVIEW

Email SMTP - Simple Mail Transfer Protocol RFC 821 POP - Post - - PowerPoint PPT Presentation

Email SMTP - Simple Mail Transfer Protocol RFC 821 POP - Post Office Protocol RFC 1939 Also: RFC 822 Standard for the Format of ARPA Internet Text Messages RFCs 1521, 1522 Mime Netprog: Email Protocols 1


slide-1
SLIDE 1

Netprog: Email Protocols 1

Email

  • SMTP - Simple Mail Transfer Protocol

– RFC 821

  • POP - Post Office Protocol

– RFC 1939

  • Also:

– RFC 822 Standard for the Format of ARPA Internet Text Messages – RFCs 1521, 1522 Mime

slide-2
SLIDE 2

Netprog: Email Protocols 2

Terminology

  • User Agent (UA): end-user mail

program

  • Message Transfer Agent(MTA):

responsible for communicating with remote hosts and transmitting/receiving email (both a client and server).

  • Mail Exchanger: host that takes care of

email for a domain.

slide-3
SLIDE 3

Netprog: Email Protocols 3

SMTP

Used to exchange mail messages between mail servers (Message Transfer Agents).

MTA MTA MTA MTA UA UA SMTP File System File System MTA MTA SMTP UA UA SMTP

slide-4
SLIDE 4

Netprog: Email Protocols 4

SMTP Protocol

  • SMTP sender is the client
  • SMTP receiver is the server.
  • Alternating dialogue:

– client sends command and server responds with command status message. – Order of the commands is important! – Status messages include ascii encoded numeric status code (like 250, 220) and text string.

slide-5
SLIDE 5

Netprog: Email Protocols 5

SMTP Commands

  • HELO - identifies sender
  • MAIL FROM: - starts a mail transaction and

identifies the mail originator

  • RCPT TO: - identifies individual recipient. There

may be multiple RCPT TO: commands.

  • DATA - sender ready to transmit a series of lines of

text, each ends with \r\n. A line containing only a period ‘.’ indicates the end of the data.

slide-6
SLIDE 6

Netprog: Email Protocols 6

Data Format

  • ASCII only- must convert binary to an

ASCII representation to send via email.

  • What if we want to send a line

containing only a period?

– Sender prepends a period to any line staring with a period (in the message). – Receiver strips the leading period in any line that starts with a period and has more stuff.

slide-7
SLIDE 7

Netprog: Email Protocols 7

Typical Exchange

wyxu@canopus % telnet hub0.engr.sc.edu 25 Trying 129.252.21.22... Connected to hub0.engr.sc.edu. Escape character is '^]'. 220 HUB0.engr.sc.edu Microsoft ESMTP MAIL Service ready at Sat, 17 Nov 2007 20:18:49 -0500 HELO 250 HUB0.engr.sc.edu Hello [129.252.130.106] MAIL from:<wyxu@engr.sc.edu> 250 2.1.0 Sender OK RCPT to:<wyxu@cse.sc.edu> 250 2.1.5 Recipient OK DATA 354 Start mail input; end with <CRLF>.<CRLF> this is a test mail . 250 2.6.0 <c2b1c1a0-3951-4fd6-b6fb-675c0ee4a0dd> Queued mail for delivery

slide-8
SLIDE 8

Netprog: Email Protocols 8

Leading Period

DATA 354 Start mail input; end with <CRLF>.<CRLF> this message is a test of SMTP .. ..foo .. . 250 2.6.0 <c2b1c1a0-3951-4fd6-b6fb-675c0ee4a0dd> Queued mail for delivery

Resulting Message: this message is a test of SMTP . .foo . this message is a test of SMTP . .foo .

slide-9
SLIDE 9

Netprog: Email Protocols 9

Other SMTP Commands

VRFY - confirm that a name is a valid recipient.

S: VRFY Smith R: 250 Fred Smith <Smith@USC-ISIF.ARPA>

EXPN - expand an alias (group email address).

S: EXPN Example-People R: 250-Jon Postel <Postel@USC-ISIF.ARPA> R: 250-Fred Fonebone <Fonebone@USC-ISIQ.ARPA> R: 250-Sam Q. Smith <SQSmith@USC-ISIQ.ARPA> R: 250-Quincy Smith <@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA> R: 250-<joe@foo-unix.ARPA> R: 250 <xyz@bar-unix.ARPA>

TURN - switch roles (sender <=> receiver).

slide-10
SLIDE 10

Netprog: Email Protocols 10

more Commands

SOML - Send Or Mail

if recipient is logged in, display message on terminal, otherwise email.

SAML - Send and Mail NOOP - send back a positive reply code. RSET - abort current transaction.

slide-11
SLIDE 11

Netprog: Email Protocols 11

Envelopes, Headers, and Body

  • Envelopes are used by MTAs for delivery

– Specified by MAIL and RCPT commands

  • MAIL from:<wyxu@engr.sc.edu>
  • RCPT to:<wyxu@cse.sc.edu>
  • Headers are used by user agents

– RFC 822 specifies header format – Each header field contains a name, a colon, and field value

  • Body is content of message from sending user to

receiving user

– When transferred using DATA command, headers are sent first, followed by a blank line, followed by body

slide-12
SLIDE 12

Netprog: Email Protocols 12

Mail Headers

  • Email messages contain many headers,

some headers are created by the UA, some are automatically added by the MTA.

  • Every MTA adds (at least) a “Received:”

header.

  • Some of the headers are read by (parsed)

intermediate MTAs, but the content is ignored and passed on transparently.

slide-13
SLIDE 13

Netprog: Email Protocols 13

Transmission of a Mail

  • User agent takes body, adds some headers,

and passes to MTA

  • MTA adds some headers, adds envelope,

and sends to another MTA

slide-14
SLIDE 14

Netprog: Email Protocols 14

Relay Agents

  • All individual systems send their mail to a relay

system

  • Two reasons of using relay system

– Simplify configuration of all MTAs other than relay system’s MTA – Allow one system at an organization to act as mail hub

  • Most organizations use relay system for Internet mail
slide-15
SLIDE 15

Netprog: Email Protocols 15

Improvements on SMTP

  • Envelope changes: Extended SMTP
  • Header changes: Non-ASCII characters
  • Body changes: Multipurpose Internet

Mail Extensions (MIME)

slide-16
SLIDE 16

Netprog: Email Protocols 16

Extended SMTP

  • Framework for adding extensions to SMTP
  • Client wishing to use new features can use

EHLO, instead of HELO, to initiate session

  • Server lists extended commands in the 250

reply to EHLO command

slide-17
SLIDE 17

Netprog: Email Protocols 17

Non-ASCII Characters

  • Allow additional characters in sender and

receiver names and in subject

  • Header can contain encoded words

=? charset ? encoding ? encoded-text ?= – Charset can be us-ascii or iso-8859-1 – Encoding can be quoted-printable (Q) or base-64 (B)

  • Using base-64, three consecutive bytes are encoded as

four 6-bit values

From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu> To:=?ISO-8859-1?Q?Keld_j=F8rn_Sim? =<test@gmail.com> Subject:=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?==?ISO- 8859-2?B?dSB1bmR1cnN0YW5kIHRoZSBleGFtcGxlLg==?=

slide-18
SLIDE 18

Netprog: Email Protocols 18

Multipurpose Internet Mail Extensions

  • Allow structures in body
  • Five new header fields

Mime-Version: Content-Type: Content-Transfer-Encoding: Content-ID: Content-Description:

  • Seven content types: text, multipart, message,

application, image, audio, video

Mime-Version:1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII

  • Five encoding formats: 7bit, quoted-printable,

base64, 8bit, binary

slide-19
SLIDE 19

Netprog: Email Protocols 19

POP – Post Office Protocol

  • Used to transfer mail from a mail server

to a UA.

Mail Server Mail Server UA UA File System File System POP

slide-20
SLIDE 20

Netprog: Email Protocols 20

POP (version 3)

  • Similar to SMTP command/reply

lockstep protocol.

  • Used to retrieve mail for a single user

– requires authentication

  • Commands and replies are ASCII lines.

– Replies start with “+OK” or “-ERR”. – Replies may contain multiple lines.

slide-21
SLIDE 21

Netprog: Email Protocols 21

POP-3 Commands

  • USER - specify username
  • PASS - specify password
  • STAT - get mailbox status

– number of messages in the mailbox.

  • LIST - get a list of messages and

sizes.

– One per line, termination line contains ‘.’ only.

  • RETR - retrieve a message
slide-22
SLIDE 22

Netprog: Email Protocols 22

More POP-3 Commands

  • DELE - mark a message for deletion

from the mailbox.

  • NOOP - send back positive reply
  • RSET - reset. All deletion marks are

unmarked.

  • QUIT - remove marked messages and

close the (TCP) connection.

slide-23
SLIDE 23

Netprog: Email Protocols 23

Optional Commands

  • TOP - send header lines from

messages.

  • APOP - alternative authentication

– message digest based on opening greeting sent from POP server. – Requires shared secret! – No cleartext password on the network. – Does not authenticate the server!!!!

slide-24
SLIDE 24

Netprog: Email Protocols 24

A Pop3 Exchange

> telnet hub0.engr.sc.edu 110 Trying 129.252.21.22... Connected to hub0.engr.sc.edu. Escape character is '^]'. +OK Microsoft Exchange Server 2007 POP3 service ready … quit +OK Microsoft Exchange Server 2007 POP3 server signing off.

slide-25
SLIDE 25

Netprog: Email Protocols 25

A Pop3 Exchange

S: <wait for connection on TCP port 110> C: <open connection> S: +OK POP3 server ready <1896.697170952@dbc.mtview.ca.us> C: USER mrose S: +OK User accepted C: PASS mrosepass S: +OK Pass accepted C: STAT S: +OK 2 320 C: LIST S: +OK 2 messages (320 octets) S: 1 120 S: 2 200 S: . C: RETR 1 S: +OK 120 octets S: <the POP3 server sends message 1> S: . C: DELE 1 S: +OK message 1 deleted C: RETR 2 S: +OK 200 octets S: <the POP3 server sends message 2> S: . C: DELE 2 S: +OK message 2 deleted C: QUIT S: +OK dewey POP3 server signing off (maildrop empty)