SMTP( 简单邮件传输协议 ) SIMPLE MAIL TRANSFER PROTOCOL RFC 2812
Introdution standard protocol part of the TCP/IP protocol defines the message format and the message transfer agent (MTA) TCP port 25 text-based protocol
Internet system User agent Mail server SMTP
Some mail agents Microsoft Outlook Foxmail Netscape Messenger Endora Mail,pine,elm
Mail Server Core of system Mailbox Message queue
SMTP SMTP was originally designed for only plain text (ASCII text) Provides reliable delivery of messages Uses TCP and message exchange between client and server Other functions: – address lookup – address verification
Scenario
SMTP Session 220 mail.cs.tcd.ie ESMTP Postfix (1.1.13) helo FooBar mail from: 250 Ok rcpt to: 250 Ok data 354 End data with. To: From: Subject: FooBar Hello World. 250 Ok: queued as A04537DB3 quit 221 Bye
SMTP commands HELO domainname startup and give your hostname MAIL MAIL FROM: mail from this address RECV TO: send it to this address VRFY address does this address actually exist (verify) EXPN address expand this address DATA start giving you the body of the mail message RSET reset state and drop current mail message NOOP do nothing DEBUG [level] set debugging level HELP give me some help please QUIT close this connection
Telnet SMTP server telnet servername 25 Helo,mail from,rcpt to,data,crlf.crlf,quit
SMTP, HTTP –Request/Reply protocols built on TCP or UDP –Designed to handle a fixed set of messages –Pull portocol and push protocol Protocol Data Format Programs SMTP RFC 822 and MIME Pine, NSMail, Eudora,… HTTP HTML Explorer, Netscape, Opera
MIME: Multipurpose Internet Mail Extensions Consists of three parts 1.Additional RFC822 Headers MIME-Version: Content-Type: Content-Transfer-Encoding: 2.Content types (and subtypes) text/plain text/rich image/gif application/postscript Multipart/mixed; boundary=“…”
MIME Encoding Mail systems assume ASCII –Only 64 valid characters A-Z, a-z, 0-9, +, / Some datatypes include arbitrary binary data (e.g. JPEG) Base64 encoding –3 bytes of data map to 4 ASCII Characters –A=0,B=1,… Also 7bit ASCII encoding –Human readable
Encoding of binary Data base64 encoding Treat every 3 bytes (24 bits) as 4 6-bit words
The Base64 Alphabet Value Encoding Value Encoding Value Encoding Value Encoding 0A17R34i51z 1B18S35j520 2C19T36k531 3D20U37l542 4E21V38m553 5F22W39n564 6G23X40o575 7H24Y41p586 8I25Z42q597 9J26a43r608 10K27b44s619 11L28c45t62+ 12M29d46u63/ 13N30e47v 14O31f48w 15P32g49x 16Q33h50y
From: Steve Zdancewic MIME-Version: 1.0 To: Subject: Example Mail Content-Type: multipart/mixed; boundary=" " This is a multi-part message in MIME format Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit This is the body Content-Type: text/plain; name="example.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="example.txt" Hello Content-Type: image/jpeg; name="doc.jpg" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="doc.jpg" /9j/4AAQSkZJRgABAQEASABIAAD//gAXQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q/9sAQwAIBgYH BgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCMcHCg3KSwwMTQ0NB8nOT04…
Mail Access Protocols
Pop3 A simple mail access protocol RFC 1939 Port 110 Computer with mailboxes runs POP server –User runs POP client on local computer –POP client can access and retrieve messages from mailbox –Requires authentication (password)
POP Commands USER - enter your user ID PASS - enter your password QUIT - quit the POP3 server LIST - list the messages and their size RETR - retrieve a message, pass it a message number DELE - delete a message, pass it a message number TOP - show the top x lines of a message, pass it a message number and the number of lines
list Retr 1 (…). quit