CSIS0234A Computer and Communication Networks
Email Service
Email
1
Reading and References L. Peterson et. al, Computer Networks: A Systems Approach, 3rd Edition, Morgan Kaufmann Section 9.2.1
IBM Redbook, “TCP/IP Tutorial and Technical Overview” Chapter 11 http://www.redbooks.ibm.com/pubs/pdfs/redbooks/gg24337 6.pdf
W. Stevens, TCP/IP Illustrated, Vol. 1, Addison-Wesley Chapter 28
Email
2
Electronic Mail outgoing message queue user mailbox user agent
SMTP SMTP SMTP mail server
user agent mail server
IMAP4
SMTP POP3
Email
user agents mail servers
mail server
user agent
Major components:
user agent
user agent
SMTP user agent
Transfer protocols Simple Mail Transfer Protocol RFC 821 (RFC 2821)
Post Office Protocol RFC 1939
Internet Message Access Protocol RFC 1730
Message Format RFC 822 MIME RFC 1521
3
Mail Clients & Servers User Agent a.k.a. “mail reader” composing, editing, reading mail messages e.g., Eudora, Outlook, elm, Netscape Messenger outgoing, incoming messages stored on server
Email
Mail Servers MTA – mail transfer agent (mail daemon) smtp protocol between mail servers to send email messages client/server
mailbox contains incoming messages (yet to be read) for user message queue of outgoing (to be sent) mail messages
4
SMTP [RFC 821 & 2821] uses TCP to reliably transfer email msg from MTA client to MTA 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
CRLF CRLF
Positive completion reply (2xx) Positive intermediate reply (3xx) Transient negative completion reply (4xx) Permanent negative completion reply (5xx)
response: status code and phrase
messages must be in 7-bit ASCII Email
5
Handshaking – connection setup Sender opens TCP connection with receiver Once connected, receiver identifies itself 220 service ready
Sender identifies itself HELO
(or EHLO)
Receiver accepts sender’s identification 250 OK
If mail service not available, step 2 above becomes: 421 service not available Email
CRLF CRLF
6
Mail Transfer Sender may send one or more messages to receivers MAIL FROM command identifies originator Gives reverse path to used for error reporting Receiver returns 250 OK or appropriate fail/error message
One or more RCPT TO commands identifies recipients for the message DATA command transfers message text End of message indicated by line containing just period (.)
Email
7
Closing Connection Two steps Sender sends QUIT and waits for reply Then initiate TCP close operation Receiver initiates TCP close after sending reply to QUIT
CRLF CRLF
Email
8
Email
9
Mail message format SMTP: protocol for exchanging email msgs RFC 822: standard for text message format:
Envelop
header lines, e.g., To: From: Subject:
Keyword followed by colon followed by arguments body Email
the “message”, ASCII characters only
10
Testing - First line. Last line. . 250 2.0.0 k2K6wLh12890 Message accepted for delivery QUIT 221 2.0.0 staff.cs.hku.hk closing connection
Email
Envelop Header Body
Blank line
MAIL FROM: SIZE=404 250 2.1.0 ... Sender ok RCPT TO: 250 2.1.5 ... Recipient ok DATA 354 Enter mail, end with "." on a line by itself Message-ID: Date: Mon, 20 Mar 2006 14:58:13 +0800 From: Anthony Tam User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To:
[email protected] Subject: Email testing Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit
11
Multipurpose Internet Mail Extension (MIME) Extension to RFC822 SMTP can not transmit executables Can not transmit text including international characters (e.g. â, å, ä, è, é, ê, ë) Servers may reject mail over certain size Translation between ASCII and EBCDIC not standard Some SMTP implementations do not adhere to standard CRLF, truncate or wrap long lines, removal of white space, etc.
Email
12
Extension Additional lines in msg header declare MIME info Five new message header fields MIME version; Content type; Content transfer encoding; Content Id; Content Description
Definitions for a set of content types image/jpeg; application/pdf; application/msword multipart/. . .
Transfer encoding defined
base64 Maps arbitrary binary input onto printable output Email
13
Multipart Type
String Token
Email
14
Mail Access Protocols user agent
SMTP
SMTP
sender’s mail server
POP3 or IMAP
user agent
receiver’s mail server
SMTP: delivery/storage to receiver’s server Mail access protocol: retrieval from server POP: Post Office Protocol [RFC 1939] authorization (agent server) and download
IMAP: Internet Mail Access Protocol [RFC 2060] more features (more complex) manipulation of stored msgs on server
HTTP: Hotmail , Yahoo! Mail, etc. Email
15
POP3 [RFC 1939] POP client connects to POP server using TCP port# 110 POP has many similarities to SMTP Text-oriented command/reply protocol Each line is terminated with CRLF
Protocol States Authorization state Transaction state Email
Update state
16
Authorization state
Transaction state
Email
+OK hello from popgate(2.30.2) USER c0234a +OK password required. PASS korwten +OK maildrop ready, 3 messages (15024 octets) (4367 262144000) STAT +OK 3 15024 LIST +OK 3 messages (15024 octets) 1 11543 2 1204 3 2277 . RETR 1 +OK 5974 octets Date: Mon, 7 Mar 2005 01:10:35 -0800 (PST) From: Yahoo! : . DELE 1 +OK message 1 marked deleted RETR 2 +OK 1204 octets X-Apparently-To:
[email protected] via 68.142.198.156; Mon, 07 Mar 2005 01:11:50 -0800 Authentication-Results: mta176.mail.dcn.yahoo.com : :
17
IMAP Limitations of POP3 Download emails to local client Cannot handle multiple mailboxes
Using TCP, server listens to port 143 Like POP3, command/response interactions Unlike POP3, Server may send info that doesn't correspond to the current command e.g., information update
Allows clients to retrieve portions of the message content instead of the whole, Email
e.g., retrieve the text portion of the multipart message
18