Content Application: Electronic Mail Linda Wu Email system model protocol MIME extensions Mail access protocols (CMPT 471 2003-3) Reference: chapter 27 Notes-19 CMPT 471 2003-3 2 Email System Model Client- model User A User B interface interface UA UA Spool Mailboxes DB Alias expander Alias expander DB Client Relay Relay Server Internet Notes-19 CMPT 471 2003-3 3 UA: user agent 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 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
: mail transfer agent MAIL FROM: usera@ RCPT TO: userb@site2.edu From: User A To: User B Reply-to: usera@other.site Date: dd/mm/yyyy Subject: Dear User B,.. Yours, User A Body Header Message Envelop The actual mail transfer is done through Unix : Sendmail, postfix, Client is needed to send email Server is needed to receive email Notes-19 CMPT 471 2003-3 5 Notes-19 CMPT 471 2003-3 6 Delayed delivery The message does not have to be delivered immediately Sender-side delay: spooling After UA creates a message, the message is delivered to spool for storage 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 Receiver-side delay After the message is received by the, it does not have to be read the receiver immediately The mail can be stored in the mailbox of the receiver Intermediate delay The intermediate s can receive mails, keep mails in their own mailboxes and spools, and send them when appropriate Notes-19 CMPT 471 2003-3 7 Notes-19 CMPT 471 2003-3 8
Email address Email address must be unique Two parts: local-part & domain-name Local-part @ Address of the mailbox on the destination machine Domain-name Domain name of a mail destination to which the mail should be delivered Mail alias expansion 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 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 Alias is also used to map incoming recipient address Notes-19 CMPT 471 2003-3 9 Notes-19 CMPT 471 2003-3 10 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 DB usera@ friends (one name) One-to-many alias expander userb@ site2.edu (many recipients) userc@ DB william@ John (one recipient) Many-to-one alias expander john@ black@ (many addresses) Notes-19 CMPT 471 2003-3 11 Notes-19 CMPT 471 2003-3 12
Simple Mail Transfer Protocol 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 Sends mail in NVT 7-bit ASCII format Cannot be used for languages not supported by 7-bit ASCII characters Cannot send binary data Notes-19 CMPT 471 2003-3 13 Commands and responses uses commands and responses to transfer mail between an and an Command Keyword: argument(s) Response A 3-digit code that may be followed by additional textual information Commands Responses Notes-19 CMPT 471 2003-3 14 Commands keyword Argument(s) HELO Sender s host name MAIL Sender of he FROM message RCPT TO Intended recipient DATA Body of the mail QUIT RSET VRFY NOOP Name of recipient to be verified Meaning To identify the 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 To verify the address of the recipient To check the status of the recipient Responses Code 220 Positive 221 reply 250 251 354 Negative reply 421 450.. 500.. Meaning Service ready Service closing transmission channel Requested command completed User not local; mail will be forwarded Start mail input Service not available Mailbox not available Syntax error; unrecognized command Notes-19 CMPT 471 2003-3 15 Notes-19 CMPT 471 2003-3 16
MAIL FROM: usera@ 250 OK RCPT TO: user2@site2.edu 250 OK DATA 354 start mail input From: User A To: User B Date: dd/mm/yyyy Subject: (Empty line) Dear user B,.... 250 OK Mail transfer The process of transferring a mail has 3 phases Connection establishment Mail transfer Connection termination Envelop Header Body Notes-19 CMPT 471 2003-3 18 Notes-19 CMPT 471 2003-3 17 MIME Extensions TCP XXXXX 220 service ready HELO: 250 OK mail transfer QUIT 221 service closed TCP 25 Connection establishment Connection termination Notes-19 CMPT 471 2003-3 19 Multipurpose Internet Mail Extensions A supplementary protocol that allows non- ASCII data to be sent through Not a mail protocol; only an extension to Can be thought of as a set of software functions that transform non-ascii data to ASCII data and vice versa User A Non-ASCII MIME 7-bit NVT ASCII 7-bit NVT ASCII User B MIME Non-ASCII 7-bit NVT ASCII Notes-19 CMPT 471 2003-3 20
MIME Extensions (cont.) MIME headers MIME defines 5 headers to be added to the original 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: 7bit, 8bit, binary, base64, quoted-printable Content-Id: uniquely identify the message Content-Description 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 Email body MIME header Notes-19 CMPT 471 2003-3 21 Notes-19 CMPT 471 2003-3 22 MIME Extensions (cont.) Base64 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 Base64 encoding table MIME Extensions (cont.) 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: The first character is = The next two are the hexadecimal representation of the byte Non-ASCII data 11001100 110011 (51) 001000 (8) 10000001 000100 (4) 00111001 111001 (57) 00100110 & Mixed ASCII & non-ascii data 01001100 L 10011101 Non-ASCII 00111001 9 01001011 K Z I E 5 ASCII data 01110011 01001000 01000100 00111001 Notes-19 CMPT 471 2003-3 23 00100110 & 01001100 L 00111101 = 00111001 9 ASCII data 01000100 D 00111001 9 01001011 K Notes-19 CMPT 471 2003-3 24
Mail Access Protocols Mail Access Protocols (cont.) Mail delivery Stage 1 () Local Stage 2 () Remote Mail box Mail access Mail access Stage 3 (Mail Access Protocol) Mail is stored in user s permanent mailbox for later retrieval Mail access protocol 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 (POP3) Internet Mail Access Protocol Version 4 (IMAP4) Notes-19 CMPT 471 2003-3 25 Notes-19 CMPT 471 2003-3 26 Mail Access Protocols (cont.) POP3 POP3 creates a TCP connection to the POP3 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 POP3 TCP XXXXX User-name OK Password OK List Email # and sizes Retrieve 1 Email 1 Retrieve N Email N TCP 110 Mail POP3 Notes-19 CMPT 471 2003-3 28
Mail Access Protocols (cont.) IMAP4 Similar functions as POP3 Mailboxes are located on the same computer as IMAP4 User runs IMAP4 to contact the and retrieve mails 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 A user can create a hierarchy of mailboxes in a folder for email storage Notes-19 CMPT 471 2003-3 29