Electronic Mail 1 Electronic Mail outgoing message queue

  • Slides: 48
Download presentation
Electronic Mail 1

Electronic Mail 1

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

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

Electronic Mail: mail servers user agent Mail Servers r mailbox contains incoming messages for

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

The Entire E-mail System 4

The Entire E-mail System 4

Mail access protocols user agent SMTP sender’s mail server access protocol user agent receiver’s

Mail access protocols user agent SMTP sender’s mail server access protocol user agent receiver’s mail server r SMTP: delivery/storage to receiver’s server r Mail access protocol: retrieval from server v v v 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: Hotmail , Yahoo! Mail, etc. 5

Electronic Mail: SMTP [RFC 2821] r uses TCP to reliably transfer email message from

Electronic Mail: SMTP [RFC 2821] r uses TCP to reliably transfer email message from client to server, port 25 v SMTP uses persistent connections r direct transfer: sending server to receiving server r three phases of transfer handshaking (greeting) v transfer of messages v closure r command/response interaction v commands: ASCII text v response: status code and phrase r SMTP uses info written on envelope of mail v v Message header r Does not look at contents v Message body r messages must be in 7 -bit ASCII r Other functions: v v E-mail address lookup E-mail address verification 6

Scenario: Alice sends message to Bob 4) SMTP client sends Alice’s message over the

Scenario: Alice sends message to Bob 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 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 mail server 4 5 6 user agent 7

Sample SMTP interaction S: C: S: C: C: C: S: 220 hamburger. edu HELO

Sample SMTP interaction S: C: S: C: C: C: S: 220 hamburger. edu HELO crepes. fr 250 Hello crepes. fr, pleased to meet you MAIL FROM: <alice@crepes. fr> 250 alice@crepes. fr. . . Sender ok RCPT TO: <bob@hamburger. edu> 250 bob@hamburger. edu. . . Recipient ok DATA 354 Enter mail, end with ". " on a line by itself Do you like ketchup? How about pickles? . 250 Message accepted for delivery QUIT 221 hamburger. edu closing connection 8

Try SMTP interaction for yourself: r telnet servername 25 r see 220 reply from

Try SMTP interaction for yourself: r telnet servername 25 r see 220 reply from server r enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands above lets you send email without using email client (reader) 9

[codd: ~] [4: 18 pm] -> telnet www. cs. uakron. edu 25 Trying 130.

[codd: ~] [4: 18 pm] -> telnet www. cs. uakron. edu 25 Trying 130. 101. 10. 1. . . Connected to vonneumann. cs. uakron. edu. Escape character is '^]'. 220 vonneumann. cs. uakron. edu ESMTP Sendmail 8. 9. 3/8. 9. 3; Mon, 12 Nov 2001 16: 18 -0500 (EST) HELO cs. uakron. edu 250 vonneumann. cs. uakron. edu Hello codd. cs. uakron. edu [130. 101. 10. 5], pleased to meet you MAIL FROM: dang@cs. uakron. edu 250 dang@cs. uakron. edu. . . Sender ok RCPT TO: dangx@uakron. edu 250 dangx@uakron. edu. . . Recipient ok DATA 354 Enter mail, end with ". " on a line by itself This is a test mail message to myself!!!. 250 Message accepted for delivery QUIT 221 vonneumann. cs. uakron. edu closing connection Connection closed by foreign host. 10

Mail Message Contents r Each queued message has: v Message text • RFC 822

Mail Message Contents r Each queued message has: v Message text • RFC 822 header with message envelope and list of recipients • Message body, composed by user v. A • • list of mail destinations Derived by user agent from header May be listed in header May require expansion of mailing lists May need replacement of mnemonic names with mailbox names 11

Possible Errors r Host unreachable r Host out of operation r TCP connection fail

Possible Errors r Host unreachable r Host out of operation r TCP connection fail during transfer r Sender can re-queue mail v Give up after a period r Faulty destination address v User error v Target user changed address v Redirect if possible v Inform user if not 12

SMTP System Overview r Commands and responses between sender and receiver r Initiative with

SMTP System Overview r Commands and responses between sender and receiver r Initiative with sender v Establishes TCP connection r Sender sends commands to receiver r e. g. HELO<SP><domain><CRLF> r Each command generates exactly one reply r e. g. 250 requested mail action ok; completed 13

SMTP Replies r Leading digit indicates category v Positive completion reply (2 xx) v

SMTP Replies r Leading digit indicates category v Positive completion reply (2 xx) v Positive intermediate reply (3 xx) v Transient negative completion reply (4 xx) v Permanent negative completion reply (5 xx) 14

Operation Phases r Connection setup r Exchange of command-response pairs r Connection termination 15

Operation Phases r Connection setup r Exchange of command-response pairs r Connection termination 15

Connection Setup r Sender opens TCP connection with receiver r Once connected, receiver identifies

Connection Setup r Sender opens TCP connection with receiver r Once connected, receiver identifies itself v 220 <domain> service ready r Sender identifies itself v HELO r Receiver accepts sender’s identification v 250 OK r If mail service not available, step 2 above becomes: v 421 service not available 16

Mail Transfer r Sender may send one or more messages to receiver r MAIL

Mail Transfer r Sender may send one or more messages to receiver r MAIL command identifies originator Gives reverse path to used for error reporting v Receiver returns 250 OK or appropriate fail/error message v r One or more RCPT commands identifies recipients for the message v Separate reply for each recipient r DATA command transfers message text v End of message indicated by line containing just period (. ) 17

Closing Connection r Two steps r Sender sends QUIT and waits for reply r

Closing Connection r Two steps r Sender sends QUIT and waits for reply r Then initiate TCP close operation r Receiver initiates TCP close after sending reply to QUIT 18

Electronic Mailboxes and Addresses r E-mail users have an electronic mailbox into which mail

Electronic Mailboxes and Addresses r E-mail users have an electronic mailbox into which mail is deposited r Usually associated with computer account; one user may have different electronic mailboxes r User accesses mail with a mail reader program r Electronic mailbox is identified by an e-mail address mailbox@computer 19

Internet Mail Addressing r User portion or mailbox portion is site specific v Dang

Internet Mail Addressing r User portion or mailbox portion is site specific v Dang v Xuan. Hien_T_Dang v 1234. 5678 r Host portion or computer portion is domain name r Source mail client v Resolves destination name using DNS (MX, if available) v Contacts mail delivery server at destination v Copies mail to server r Destination mail server v Interprets user name according to local mailbox addresses v Places mail in appropriate mailbox 20

E-mail message format r Simple two-part format v Header includes delivery information v Body

E-mail message format r Simple two-part format v Header includes delivery information v Body carries text of message r Header and body separated by blank line 21

Mail message format SMTP: protocol for exchanging email msgs RFC 822: standard for text

Mail message format SMTP: protocol for exchanging email msgs RFC 822: standard for text message format: r header lines, e. g. , To: v From: v Subject: different from SMTP commands! v header blank line body r body v the “message”, ASCII characters only 22

E-mail Headers r Lines of text in format keyword: information r keyword identifies information;

E-mail Headers r Lines of text in format keyword: information r keyword identifies information; information can appear in any order r Essential information: v v v To: list of recipients From: sender Cc: list of copy recipients r Useful information v Reply-to: different address than From: v Received-by: for debugging r Frivolous information: v Favorite drink: lemonade v Phase-of-the-moon: gibbous 23

Data in E-mail r Original Internet mail carried only 7 -bit ASCII data r

Data in E-mail r Original Internet mail carried only 7 -bit ASCII data r Couldn’t contain arbitrary binary values; e. g. , executable program r Techniques for encoding binary data allowed transport of binary data r Uuencode: three 8 -bit binary values as four ASCII characters (6 bits each) v v v Also carries file name and protection information Incurs 33% overhead Requires manual intervention 24

Multipurpose Internet Mail Extension (MIME) r Extension to RFC 822 r SMTP cannot transmit

Multipurpose Internet Mail Extension (MIME) r Extension to RFC 822 r SMTP cannot transmit executables v Uuencode and other schemes are available • Not standardized r Can not transmit text including international characters (e. g. â, å, ä, è, é, ê, ë) v Need 8 bit ASCII r Servers may reject mail over certain size r Translation between ASCII and EBCDIC not standard r SMTP gateways to X. 400 can not handle none text data in X. 400 messages r Some SMTP implementations do not adhere to standard v CRLF, truncate or wrap long lines, removal of white space, etc. 25

MIME r MIME extends and automates encoding mechanisms r Allows inclusion of separate components

MIME r MIME extends and automates encoding mechanisms r Allows inclusion of separate components – programs, pictures, audio clips – in a single mail message r Sending program identifies the components so receiving program can automatically extract and inform mail recipient v v Header includes MIME-Version: 1. 0 Content-Type: Multipart/Mixed; Boundary=Mime_separator Separator line gives information about specific encoding Content-Type: text/plain 26

MIME (cont. ) r MIME is extensible – sender and receiver agree on encoding

MIME (cont. ) r MIME is extensible – sender and receiver agree on encoding scheme r MIME is compatible with existing mail systems Everything encoded as ASCII v Headers and separators ignored by non-MIME mail systems v r MIME encapsulates binary data in ASCII mail envelope 27

MIME 28

MIME 28

Overview of MIME r Five new message header fields v MIME version v Content

Overview of MIME r Five new message header fields v MIME version v Content type v Content transfer encoding v Content Id v Content Description 29

Content Types r Text body r Multipart v Mixed, Parallel, Alternative, Digest r Message

Content Types r Text body r Multipart v Mixed, Parallel, Alternative, Digest r Message v RFC 822, Partial, External-body r Image v jpeg, gif r Video v mpeg r Audio v Basic r Application v Postscript v octet stream 30

MIME Transfer Encodings r Quoted-printable v Data largely printable ASCII characters v Non-printing characters

MIME Transfer Encodings r Quoted-printable v Data largely printable ASCII characters v Non-printing characters represented by hex code r Base 64 v Maps arbitrary binary input onto printable output 31

Message format: multimedia extensions r MIME: multimedia mail extension, RFC 2045, 2056 r additional

Message format: multimedia extensions r MIME: multimedia mail extension, RFC 2045, 2056 r additional lines in msg header declare MIME content type MIME version method used to encode data multimedia data type, subtype, parameter declaration encoded data From: alice@crepes. fr To: bob@hamburger. edu Subject: Picture of yummy crepe. MIME-Version: 1. 0 Content-Transfer-Encoding: base 64 Content-Type: image/jpeg base 64 encoded data. . . . . base 64 encoded data 32

Programs as mail recipients r Can arrange for e-mailbox to be associated with a

Programs as mail recipients r Can arrange for e-mailbox to be associated with a program rather than a user’s mail reader r Incoming mail automatically processed as input to program r Example – mailing list subscription administration 33

Mailing Lists and Forwarders r E-mail addresses can be attached to programs as well

Mailing Lists and Forwarders r E-mail addresses can be attached to programs as well as electronic mailboxes r Mail exploder or mail forwarder resends copies of message to e-mail addresses in mailing list UNIX mail program sendmail provides mail aliases v Mailing list processor, e. g. listserv, can also interpret subscription management commands v 34

Mail Gateways r Mailing list processing may take significant resources in large organizations r

Mail Gateways r Mailing list processing may take significant resources in large organizations r May be segregated to a dedicated server computer: mail gateway Provides single mail destination point for all incoming mail v Can use MX records in DNS to cause all mail to be delivered to gateway v 35

Mail gateways and forwarding r Users within an organization may want to read mail

Mail gateways and forwarding r Users within an organization may want to read mail on local or departmental computer r Can arrange to have mail forwarded from mail gateway r Message now makes multiple hops for delivery r Hops may be recorded in header r Forwarded mail may use proprietary (non. SMTP) mail system 36

Mail Gateways and E-mail Addresses r Organization may want to use uniform naming for

Mail Gateways and E-mail Addresses r Organization may want to use uniform naming for external mail r Internally, may be delivered to many different systems with different naming conventions r Mail gateways can translate e-mail addresses 37

Mail Access Protocols r User agent accesses a mailbox from a shared mail server

Mail Access Protocols r User agent accesses a mailbox from a shared mail server r Mail access protocol transfers mail from server to local PC r 2 popular protocols: POP 3 (Post Office Protocol v 3) v IMAP (Internet Mail Access Protocol) v r Can’t use SMTP because getting messages is a pull operation & SMTP is a push protocol. 38

Mail Access Protocol r Instead of TELNET, use protocol that accesses mail on remote

Mail Access Protocol r Instead of TELNET, use protocol that accesses mail on remote computer directly r TCP/IP suite includes Post Office Protocol (POP) for remote mailbox access Computer with mailboxes runs POP server v User runs POP client on local computer v POP client can access and retrieve messages from mailbox v Requires authentication (password) v Local computer uses SMTP for outgoing mail v 39

POP 3 and SMTP 40

POP 3 and SMTP 40

POP 3 r Three phases v Authorization v Transaction v Update r During a

POP 3 r Three phases v Authorization v Transaction v Update r During a POP 3 session, the server maintains state information r POP 3 downloads mail messages to the local machine 41

POP 3 protocol authorization phase r client commands: v v user: declare username pass:

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

Dialup Access and POP r POP useful for dialup connection v User’s computer not

Dialup Access and POP r POP useful for dialup connection v User’s computer not always connected v Can download all mail at once and read off-line v Can compose mail off-line and mail in one connection 43

IMAP r Internet Mail Access Protocol r Allows users to manipulate remote mailboxes r

IMAP r Internet Mail Access Protocol r Allows users to manipulate remote mailboxes r Must maintain info about user (e. g. , folder hierarchy) even after the user quits r IMAP server is always in 1 of 4 states: Nonauthenticated v Authenticated v Selected v Logout v 44

POP 3 and IMAP More about POP 3 r Previous example uses “download and

POP 3 and IMAP More about POP 3 r Previous example uses “download and delete” mode. r Bob cannot re-read email if he changes client r “Download-and-keep”: copies of messages on different clients r POP 3 is stateless across sessions IMAP r Keep all messages in one place: the server r Allows user to organize messages in folders r IMAP keeps user state across sessions: v names of folders and mappings between message IDs and folder name 45

Web-based Emails r Problem: Suppose Alice, with a web-based email account (such as Hotmail),

Web-based Emails r Problem: Suppose Alice, with a web-based email account (such as Hotmail), sends a message to Bob, who accesses his mail from his mail server using POP 3. Discuss how the message gets from Alice’s host to Bob’s host. Be sure to list the series of applicationlayer protocols that are used to move the message between the two hosts. r Solution: Message is sent from Alice’s host to her mail server over HTTP. Alice’s mail server then sends the message to Bob’s mail server over SMTP. Bob then transfers the message from his mail server to his host over POP 3. 46

SMTP, FTP and HTTP r Connections: – All use TCP – SMTP uses persistent

SMTP, FTP and HTTP r Connections: – All use TCP – SMTP uses persistent connections – FTP persistent control channel, non-persistent data channel per file. – HTTP uses both persistent and non-persistent channels r Data Flow – FTP and HTTP: pull (user requests files) – SMTP: push (email sent to receiver without request, result can be spam!) r All have ASCII command/response interaction, status codes r HTTP: each object encapsulated in its own response msg r FTP: one data channel per file r SMTP: multiple objects sent in multipart msg 47

Summary for Email r Electronic mail allows quick, asynchronous communication across entire Internet. r

Summary for Email r Electronic mail allows quick, asynchronous communication across entire Internet. r Simple Mail Transfer Protocol (SMTP) is Internet standard for mail delivery r Can attach e-mail addresses to programs for processing v v Mailing lists Other client-server applications r Mail gateways v Provide uniform user addressing outside organizations v Translate from Internet mail (e. g. SMTP) to proprietary systems r Post Office Protocol (POP) and Internet Mail Access Protocol (IMAP) allow remote access to electronic mailboxes. 48