Application Electronic Mail Linda Wu CMPT 471 2003

  • Slides: 29
Download presentation
Application: Electronic Mail Linda Wu (CMPT 471 • 2003 -3)

Application: Electronic Mail Linda Wu (CMPT 471 • 2003 -3)

Content ¡ ¡ Email system model SMTP protocol MIME extensions Mail access protocols Reference:

Content ¡ ¡ Email system model SMTP protocol MIME extensions Mail access protocols Reference: chapter 27 Notes-19 CMPT 471 2003 -3 2

Email System Model ¡ Client-server model User A (sender) User B (receiver) interface UA

Email System Model ¡ Client-server model User A (sender) User B (receiver) interface UA UA Spool DB Client Notes-19 Mailboxes Alias expander MTA Alias expander Relay MTA Internet CMPT 471 2003 -3 MTA DB Server 3

Email System Model (cont. ) ¡ UA: user agent l l A program used

Email System Model (cont. ) ¡ UA: user agent l l A program used by the user to send and receive emails, e. g. , mutt, elm, pine, Eudora, Outlook Express Sending email The user creates mail through the UA ¡ The mail has an envelop and a message ¡ l Receiving email UA checks the mailboxes periodically ¡ Displays a message list, in which each line is a summary about a particular message in the mailbox: sender email address, subject, the time the mail was sent or received ¡ Notes-19 CMPT 471 2003 -3 4

Notes-19 From: User A To: User B Reply-to: usera@other. site Date: dd/mm/yyyy Subject: ……

Notes-19 From: User A To: User B Reply-to: usera@other. site Date: dd/mm/yyyy Subject: …… Header Dear User B, ……. . Yours, User A Body MAIL FROM: usera@site 1. com RCPT TO: userb@site 2. edu CMPT 471 2003 -3 Message Envelop Email System Model (cont. ) 5

Email System Model (cont. ) ¡ MTA: mail transfer agent l l Notes-19 The

Email System Model (cont. ) ¡ MTA: mail transfer agent l l Notes-19 The actual mail transfer is done through MTA Unix MTA: Sendmail, postfix, …… Client MTA is needed to send email Server MTA is needed to receive email CMPT 471 2003 -3 6

Email System Model (cont. ) ¡ Delayed delivery The message does not have to

Email System Model (cont. ) ¡ Delayed delivery The message does not have to be delivered immediately l Sender-side delay: spooling After UA creates a message, the message is delivered to spool for storage ¡ MTA periodically (10~30 mins) checks the mail in the spool to see if it can be sent ¡ If the message cannot be sent, it remains in the spool to be checked in the next cycle ¡ If a message cannot be delivered in the time-out period (3~5 days), it is returned to the sender ¡ Notes-19 CMPT 471 2003 -3 7

Email System Model (cont. ) l Receiver-side delay After the message is received by

Email System Model (cont. ) l Receiver-side delay After the message is received by the MTA, it does not have to be read the receiver immediately ¡ The mail can be stored in the mailbox of the receiver ¡ l Intermediate delay ¡ Notes-19 The intermediate MTAs can receive mails, keep mails in their own mailboxes and spools, and send them when appropriate CMPT 471 2003 -3 8

Email System Model (cont. ) ¡ Email address l l Email address must be

Email System Model (cont. ) ¡ Email address l l Email address must be unique Two parts: local-part & domain-name Local-part @ Domain-name Address of the mailbox on the destination machine Notes-19 Domain name of a mail destination to which the mail should be delivered CMPT 471 2003 -3 9

Email System Model (cont. ) ¡ Mail alias expansion l One-to-many alias expansion User

Email System Model (cont. ) ¡ Mail alias expansion l One-to-many alias expansion User can create an alias that is mapped to a list of recipients (mailing list) ¡ The recipients on a list need not to be local ¡ For an outgoing message ¡ l l ¡ Notes-19 Check the recipient’s name against the alias expansion database If there is an expansion, replace the recipient with the mapped version, and pass the message to MTA Alias is also used to map incoming recipient address CMPT 471 2003 -3 10

Email System Model (cont. ) l Many-to-one alias expansion A user can have several

Email System Model (cont. ) l Many-to-one alias expansion A user can have several email addresses, but the user agent only recognizes one mailbox name ¡ When a system receives mail, it checks the many-to-one expansion database ¡ If a mailbox name corresponding to the local part of the received address is found, the mail is sent to that mailbox; otherwise, it is discarded ¡ Notes-19 CMPT 471 2003 -3 11

Email System Model (cont. ) friends (one name) DB John (one recipient) One-to-many alias

Email System Model (cont. ) friends (one name) DB John (one recipient) One-to-many alias expander DB Many-to-one alias expander usera@ userb@ userc@ site 1. com site 2. edu site 1. com william@ john@ black@ site 1. com (many recipients) (many addresses) Notes-19 CMPT 471 2003 -3 12

Simple Mail Transfer Protocol ¡ SMTP l l Focuses on how the underlying mail

Simple Mail Transfer Protocol ¡ SMTP l l Focuses on how the underlying mail delivery system passes mails across an internet Does NOT specify: How the mail system accepts mail from a user ¡ How the user interface presents the user with incoming mail ¡ How the mail is stored ¡ l l l Notes-19 Sends mail in NVT 7 -bit ASCII format Cannot be used for languages not supported by 7 -bit ASCII characters Cannot send binary data CMPT 471 2003 -3 13

Simple Mail Transfer Protocol (cont. ) ¡ Commands and responses l l SMTP uses

Simple Mail Transfer Protocol (cont. ) ¡ Commands and responses l l SMTP uses commands and responses to transfer mail between an MTA client and an MTA server Command ¡ l Keyword: argument(s) Response ¡ A 3 -digit code that may be followed by additional textual information MTA client Notes-19 Commands Responses CMPT 471 2003 -3 MTA server 14

Simple Mail Transfer Protocol (cont. ) Commands keyword Argument(s) HELO Sender’s host name MAIL

Simple Mail Transfer Protocol (cont. ) Commands keyword Argument(s) HELO Sender’s host name MAIL Sender of the FROM message RCPT TO Intended recipient DATA Body of the mail QUIT RSET VRFY NOOP Notes-19 Meaning To identify the client itself To identify the sender of the mail To identify mail recipient To send the actual message To terminate the message To abort the current mail transaction Name of recipient To verify the address of to be verified the recipient To check the status of the recipient CMPT 471 2003 -3 15

Simple Mail Transfer Protocol (cont. ) Responses Code … Positive reply Negative reply ……

Simple Mail Transfer Protocol (cont. ) Responses Code … Positive reply Negative reply …… 220 Service ready 221 Service closing transmission channel 250 Requested command completed 251 User not local; mail will be forwarded 354 Start mail input 421 Service not available 450 Mailbox not available . . 500. . Notes-19 Meaning …… Syntax error; unrecognized command …… CMPT 471 2003 -3 16

Notes-19 MTA server Envelop CMPT 471 Header 2003 -3 Body 250 OK . ….

Notes-19 MTA server Envelop CMPT 471 Header 2003 -3 Body 250 OK . …. . . Dear user B, (Empty line) Subject: …… Date: dd/mm/yyyy To: User B From: User A 354 start mail input DATA 250 OK RCPT TO: user 2@site 2. edu 250 OK MAIL FROM: usera@site 1. com MTA client Simple Mail Transfer Protocol (cont. ) 17

Simple Mail Transfer Protocol (cont. ) ¡ Mail transfer l The process of transferring

Simple Mail Transfer Protocol (cont. ) ¡ Mail transfer l The process of transferring a mail has 3 phases Connection establishment ¡ Mail transfer ¡ Connection termination ¡ Notes-19 CMPT 471 2003 -3 18

Simple Mail Transfer Protocol (cont. ) MTA client TCP XXXXX TCP connection ready 220

Simple Mail Transfer Protocol (cont. ) MTA client TCP XXXXX TCP connection ready 220 service ready HELO: site 1. com MTA TCP 25 server Email transfer connection establishment 250 OK … mail transfer … QUIT 221 service closed Notes-19 CMPT 471 2003 -3 Email transfer connection termination 19

MIME Extensions ¡ Multipurpose Internet Mail Extensions l l l A supplementary protocol that

MIME Extensions ¡ Multipurpose Internet Mail Extensions l l l A supplementary protocol that allows non. ASCII data to be sent through SMTP Not a mail protocol; only an extension to SMTP Can be thought of as a set of software functions that transform non-ASCII data to ASCII data and vice versa User A User B Non-ASCII MIME 7 -bit NVT ASCII SMTP Notes-19 MIME 7 -bit NVT ASCII CMPT 471 2003 -3 7 -bit NVT ASCII SMTP 20

MIME Extensions (cont. ) ¡ MIME headers l l MIME defines 5 headers to

MIME Extensions (cont. ) ¡ MIME headers l l MIME defines 5 headers to be added to the original SMTP header section The headers define the transformation parameters MIME-Version: current version is 1. 1 ¡ Content-Type: text/plain, image/jpeg, image/gif, multipart/mixed, application/postscript, …… ¡ Content-Transfer-Encoding: 7 bit, 8 bit, binary, base 64, quoted-printable ¡ Content-Id: uniquely identify the message ¡ Content-Description ¡ Notes-19 CMPT 471 2003 -3 21

MIME Extensions (cont. ) Email header MIME-Version: 1. 1 Content-Type: type/subtype Content-Transfer-Encoding: encoding type

MIME Extensions (cont. ) Email header MIME-Version: 1. 1 Content-Type: type/subtype Content-Transfer-Encoding: encoding type Content-Id: message id Content-Description: textual explanation of nontextual contents MIME header Email body Notes-19 CMPT 471 2003 -3 22

MIME Extensions (cont. ) l Base 64 encoding Divide the binary data into 24

MIME Extensions (cont. ) l Base 64 encoding Divide the binary data into 24 -bit blocks ¡ Each blocks is then divided into four 6 -bit sections ¡ Interpret each 6 -bit section as one character according to Base 64 encoding table ¡ Non-ASCII data 1100 10000001 001110011 001000 000100 111001 (51) (8) (4) (57) Z I E 5 ASCII data 01110011 01001000 0100 00111001 Notes-19 CMPT 471 2003 -3 23

MIME Extensions (cont. ) l Quoted-printable encoding If a character is ASCII, it is

MIME Extensions (cont. ) l Quoted-printable encoding If a character is ASCII, it is sent as it is ¡ If a character is not ASCII, it is sent as 3 characters: ¡ l l The first character is “=” The next two are the hexadecimal representation of the byte Mixed ASCII & non-ASCII data 001001100 10011101 00111001 01001011 & L Non-ASCII 9 K 001001100 00111101 00111001 01001011 & L = 9 D 9 K ASCII data Notes-19 CMPT 471 2003 -3 24

Mail Access Protocols ¡ Mail delivery SMTP client Local SMTP Stage server Stage 1

Mail Access Protocols ¡ Mail delivery SMTP client Local SMTP Stage server Stage 1 2 (SMTP) Remote SMTP server Mail box Mail access server Mail access Stage client 3 (Mail Access Protocol) Notes-19 CMPT 471 2003 -3 25

Mail Access Protocols (cont. ) Mail is stored in user’s permanent mailbox for later

Mail Access Protocols (cont. ) Mail is stored in user’s permanent mailbox for later retrieval ¡ Mail access protocol ¡ l l l To retrieve mails from a permanent mailbox to a local computer To manipulate the mailbox content Two popular mail access protocols Post Office Protocol Version 3 (POP 3) ¡ Internet Mail Access Protocol Version 4 (IMAP 4) ¡ Notes-19 CMPT 471 2003 -3 26

Mail Access Protocols (cont. ) ¡ POP 3 l l POP 3 client creates

Mail Access Protocols (cont. ) ¡ POP 3 l l POP 3 client creates a TCP connection to the POP 3 server on the mailbox computer Server authenticates the session using user-name and password Client sends commands to retrieve a copy of one or more messages Two modes Delete mode: the mail is deleted from the mailbox after each retrieval ¡ Keep mode: the mail remains in the mailbox after retrieval ¡ Notes-19 CMPT 471 2003 -3 27

Mail Access Protocols (cont. ) User computer POP 3 client Mail server TCP XXXXX

Mail Access Protocols (cont. ) User computer POP 3 client Mail server TCP XXXXX TCP 110 POP 3 server User-name OK Password OK List Email # and sizes Retrieve 1 Email 1 …… Retrieve N Notes-19 Email N CMPT 471 2003 -3 28

Mail Access Protocols (cont. ) ¡ IMAP 4 l Similar functions as POP 3

Mail Access Protocols (cont. ) ¡ IMAP 4 l Similar functions as POP 3 Mailboxes are located on the same computer as IMAP 4 server ¡ User runs IMAP 4 client to contact the server and retrieve mails ¡ l Extended functions A user can check the email header, or, search the contents of the mails for a specific string, before downloading ¡ A user can partially download mail ¡ A user can create, delete, or remove mailboxes on the mail server ¡ A user can create a hierarchy of mailboxes in a folder for email storage ¡ Notes-19 CMPT 471 2003 -3 29