Outline • Mail Reader and Mail Server • Mail Message Format • Mail Protocols • Sample MIME messages • Practices • References
Mail Reader and Mail Server • Mail Reader • Email program that allows a user t create, edit, store and forward e-mail messages • Mail Reader is also called UA (User Agent) • Such as Outlook Express, Netscape Composer, ping, elm • Mail Server • A program (aka a daemon or a server) that in charge of storing and forwarding e-mail messages • Mail Server is also called MTA (Mail Transfer Agent), function like postman and post-office. • Such as sendmail, qmail, Microsoft Exchange
Mail Message Format (RFC 2822) • A mail message consists of a header followed, optionally, by a body. • Header fields (see example above) contains From: , To: , Subject, Date: ...etc. • Body contains what user wants to say (including nontext-based information, such as html, image, or attached files). Header A blank line Body
Mail Message Format (RFC 2822) • RFC 822 headers • RFC 822 headers added by MIME
Mail Protocols • SMTP (Simple Mail Transfer Protocol) 25 • An internet protocol for sending (transferring) e-mail • Both Mail reader and Mail Server (daemons) speak SMTP to transfer e-mail, the mail server accepts connection on port 25 and copies mail messages into appropriate mailboxes. • POP3 (110), IMAP (143) • POP/IMAP allow mail reader to receive e-mail messages. • POP3 stands for Post Office Protocol version 3 • IMAP stands for Internet Message Access Protocol • Both support offline reading (download to PC) • IMAP allow user to create and manipulate folders and mailboxes and more functionalities.
Mail Protocols • MIME (Multipurpose Internet Mail Extensions) RFC 1341 • MIME add structure to the message header and body and defining encoding rules for non-ASCII messages. With MIME, we can send multimedia mail message, including html mail, image, Rich Text Format document (RTF), and attached files and in different languages (such as Chinese, Japanese, Hebrew). • RFC 822 headers added by MIME
Mail Protocols • The MIME content types and subtypes defined in RFC2045, 2046.
Mail Protocols • The MIME content transfer encoding (tells how the body is wrapped for transmission), currently there are five schemes provided to encode non-ASCII material:
Sample MIME messages Header From: James Bond<email@example.com>To: Indiana Jones Subject: Hello from 007 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="XXXXboundary text" --XXXXboundary text Content-Type: text/plain this is the body text --XXXXboundary text Content-Type: text/plain; Content-Disposition: attachment; filename="test.txt" this is the attachment text --XXXXboundary text-- A blank line 1st body part Body 2nd body part
Sample MIME message • A text/html MIME mail message with pictures.
Header 1st body part(text/html) 2nd body part(image/gif)
Practices • Installing a Mail Server (Winmail is suggested) • Sending Email via Telnet • Receiving Email using Mail Reader • Setting up • Inside out the Message format • Monitoring the interaction of mail client and server using sockspy • Receiving Email via telnet (POP3) • Sending a Simple HTML mail • Sending a multimedia mail (html, image and attachments, refer to reference for online base64 encoding) • Writing a simple mail client using Tcl, PHP or... (better have SMTP Authentication support, hint: AUTH LOGIN and Tcllib base64 package)
References • Computer Networks 4th Edition Chap7.2, Andrew S. Tanenbaum, Prentice Hall, 2003/03 • online base64 encoding • http://www.motobit.com/util/base64-decoder-encoder.asp • Sending e-mail via Telnet • http://www.activexperts.com/activemail/telnet/ • How to send an e-mail with attached file • http://www.hochfeiler.it/alvise/smtp.htm • Telnet POP3 Tutorial • http://manual.liquidweb.com/chapter3/pop3.htm • SMTP Auth Email Script (PHP) • http://codewalkers.com/getcode.php?id=538