petrozavodsk state university, alex moschevikin, 2003

23
Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES E-mail Internet Protocols •Simple Mail Transfer Protocol, SMTP RFC821 (August 1982) •Post Office Protocol, POP3 RFC 1939 (May 1996) •Internet Message Access Protocol, IMAP4 First RFC concerning IMAP - 1986 year RFC 1730 (IMAP4, December 1994) RFC 3501 (new edition of IMAP4v1, March 2003) Rev. 1.04 / 11.01.2008

Upload: dandre

Post on 11-Jan-2016

20 views

Category:

Documents


1 download

DESCRIPTION

E-mail Internet Protocols. Simple Mail Transfer Protocol, SMTP RFC821 (August 1982) Post Office Protocol, POP3 RFC 1939 (May 1996) Internet Message Access Protocol, IMAP4 First RFC concerning IMAP - 1986 year RFC 1730 (IMAP4, December 1994) RFC 3501 (new edition of IMAP4v1, March 2003). - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

E-mail Internet Protocols

•Simple Mail Transfer Protocol, SMTPRFC821 (August 1982)

•Post Office Protocol, POP3RFC 1939 (May 1996)

•Internet Message Access Protocol, IMAP4First RFC concerning IMAP - 1986 yearRFC 1730 (IMAP4, December 1994)RFC 3501 (new edition of IMAP4v1, March 2003)

Rev. 1.04 / 11.01.2008

Page 2: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

E-mail transport scheme

MTA - Mail Transfer AgentMDA - Mail Delivery Agent

Mail Client,MTA (The Bat,

Outlook)

SMTP server 1,

MTA

SMTP

SMTP server 2,

MTA

SMTP SMTP destination

server, MTA

SMTP

MDA

Mail Client,(The Bat, Outlook)

POP3

IMAP4

POP3 server

IMAP server

telnet

User's mailboxes

Page 3: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

E-mail protocols and OSI RM

APPLICATION

PRESENTATION

SESSION

TRANSPORT

NETWORK

DATA LINK

PHYSICAL

Layer 7

Layer 6

Layer 5

Layer 4

Layer 3

Layer 2

Layer 1

TCP

IP

Physical

TCP/IP OSI/RM

SMTP, POP3, IMAP4

Page 4: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

SMTP features

•Purpose: to transfer messages across a network.

•In a single session multiple mail and information messages can be transmitted in either direction across the link.

•By default an SMTP client application will contact the remote server using TCP/IP application port number 25 as the destination port, and will select at random a port from the dynamic or private range for the source port number.

•SMTP provides a mechanism that allows mail to be sent directly from sender to recipient, or through intermediate hosts if there is no direct path from one to the other (DNS: MX record).

Page 5: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

SMTP commands

HELO domain identify the client to the server ("hello, I'm...")

MAIL FROM: reverse-path

initiate mail transaction; arg is sender's address

RCPT TO: forward-path

recipient's address (issue for each recipient once)

DATA followed by the mail message (up to CRLF.CRLF)

HELP [command] ask for general help or about a specific command

RSET abort current mail transaction, reply OK

NOOP no-op, server responds OK

QUIT terminate session, server responds OK

TURN change roles: server/client; server may refuse

. . . . . .

Page 6: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

SMTP replies

Standard reply codes:

221 (domain) Service closing transmission channel 220 (domain) Service ready 250 Requested mail action okay, completed 251 User not local; will forward to (forward-path) 354 Start mail input; end with (CRLF).(CRLF) 421 (domain) Service not available, 500 Syntax error, command unrecognized 501 Syntax error in parameters or arguments 551 User not local; please try “forward-path” 552 Requested mail action aborted: exceeded storage allocation 554 Transaction failed

Page 7: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

SMTP session exampleS: Listen for connection on TCP port 25C: Connect to TCP port 25 on SMTP serverS: 220 mail.server.ru SMTP readyC: HELO my.domain.nameS: 250 mail.server.ru C: MAIL FROM:<[email protected]>S: 250 OKC: RCPT TO:<[email protected]>S: 250 OKC: RCPT TO:<[email protected]>S: 550 No such user hereC: RCPT TO:<[email protected]>S: 250 OKC: DATAS: 354 Start mail input; end with <CRLF>.<CRLF>C: Blah blah blah...C: ...etc, etc, etc.C: <CRLF>.<CRLF>S: 250 OKC: QUITS: 221 mail.server.arpa Service closing transmission channel

Page 8: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

Mail message structureReceived: from mx10.mail.ru (mx10.mail.ru [194.67.57.20]) (5) by dfe3300.karelia.ru (8.9.0/8.9.0) with ESMTP id JAA02601 for <[email protected]>; Thu, 18 Apr 2002 09:19:13 +0400Received: from f5.int ([10.0.0.57] helo=f5.mail.ru) (4) by mx10.mail.ru with esmtp (Exim MX.A) id 16y46p-0002ox-00 for [email protected]; Thu, 18 Apr 2002 09:05:27 +0400 Received: from mail by f5.mail.ru with local (Exim FE.5) (3) id 16y46o-000CfY-00 for [email protected]; Thu, 18 Apr 2002 09:05:26 +0400 Received: from [213.59.200.7] by win.mail.ru with HTTP; (2) Thu, 18 Apr 2002 09:05:26 +0400From: "Testing" <[email protected]>To: [email protected]: For testing purposes onlyMime-Version: 1.0X-Mailer: mPOP Web-Mail 2.19X-Originating-IP: [213.59.200.7] (1)Date: Thu, 18 Apr 2002 09:05:26 +0400Reply-To: "Testing" <[email protected]>Content-Type: text/plain; charset=koi8-rContent-Transfer-Encoding: 8bitMessage-Id: <[email protected]>X-UIDL: 74fb663e2be8352b3a0b88ca08030c1e Тестовое сообщение.

BLUE text was created by originating mail agent (mail client).

4 headers (Received:) were added on each SMTP interaction (hop) (2-5).

Page 9: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

CC: and BCC: headers

CC - carbon copyBCC - "blind" carbon copy

When sending mail message through BCC mechanism to multiple recipients, they do not know about the fact of spam.

MTA cuts out < BCC: … > string from message body and then sends multiple distinct letters using RCPT command.

Page 10: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

POP3 features

•Purpose: to retrieve mail from server.

•Dedicated client and server hosts.

•POP3 service is mapped to TCP port 110.

•When the TCP connection is established, the POP3 server sends a greeting. The client and POP3 server then exchange commands and responses (respectively) until the connection is closed or aborted.

•Multistring reply must end by <CRLF>.<CRLF>

Page 11: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

POP3 commands

USER name string identifying a mailbox (required)

PASS passwd a server/mailbox-specific password (required)

APOP name MD5digest

a string identifying a mailbox and a MD5 digest string (both required)

STAT inquire the content of mailbox (reply: +OK 2 320 -- 2 messages of overall volume of 320 octets)

LIST [msg] list [all] messages

RETR msg retrieve the certain message

DELE msg delete the certain message

RSET reset all previous prepared actions, reply +OK

NOOP no-op, server responds +OK

QUIT terminate session

. . . . . .

Page 12: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

POP3 session exampleS: <wait for connection on TCP port 110>C: <open connection>S: +OK POP3 server ready <[email protected]>C: APOP mrose c4c9334bac560ecc979e58001b3e22fbS: +OK mrose's maildrop has 2 messages (320 octets)C: LISTS: +OK 2 messages (320 octets)S: 1 120S: 2 200S: .C: RETR 1S: +OK 120 octetsS: <the POP3 server sends message 1>S: .C: DELE 1S: +OK message 1 deletedC: RETR 2S: +OK 200 octetsS: <the POP3 server sends message 2>S: .C: DELE 2S: +OK message 2 deletedC: QUITS: +OK dewey POP3 server signing off (maildrop empty)C: <close connection>S: <wait for next connection>

Page 13: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP vs POP3

•POP3: all messages are downloaded to the client and then deleted from server.

•IMAP: accesses remote mail-boxes as if they were present on the local machine.

The IMAP4 client can request any part of the message, such as the envelope or the headers and download the whole message only when needed.

Server based searching is also supported.Messages are not deleted immediately, rather they are marked

for deletion and only removed once the client logs off or sends the expunge command.

•POP3: useful for people working with one computer.•IMAP: Because the messages are stored on the server, it doesn't really

matter who or where the client is (synchronization).

Page 14: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP4v1 description

•Purpose: to allows a client to access and manipulate electronic mail messages on a server.

•Messages in IMAP4rev1 are accessed by the use of numbers. These numbers are either message sequence numbers or unique identifiers.

• The IMAP4rev1 protocol assumes a reliable data stream such as that provided by TCP. When TCP is used (!), an IMAP4rev1 server listens on port 143.

• The client command begins an operation. Each client command is prefixed with an identifier (typically a short alphanumeric string, e.g., A0001, A0002, etc.) called a "tag". A different tag is generated by the client for each command.

•Client need not wait for reply on certain command, it can issue next command to execute

Page 15: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP4v1 session states

Transport connection and server greeting

Non-authenticated

Authenticated (operations involving

mailboxes)

Selected(operations involving

messages)

Logout, break or close connection

greeting/byegreeting/

PREAUTH

greeting/OK LOGINsuccessful

SELECT / EXAMINE

Page 16: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP4v1 description cont'd

•Unique Identifier (UID) (32 bit, greater than previous)•Message Sequence Number (position of message in mailbox, can be

reassigned during the session)•Internal date•Size•Envelope structure (parsed headers part)•Body structure (parsed structure of MIME content)•Flags:

1.\Seen Message has been read2.\Answered Message has been answered3.\Flagged Message is "flagged" for urgent/special

attention4.\Deleted Message is "deleted" for removal by later

EXPUNGE5.\Draft Message is marked as a draft.6.\Recent Message is "recently" arrived in this mailbox

(only for 1st read-write session).

Message attributes:

Page 17: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP4v1 client commands

CAPABILITY: requests a listing of capabilities that the server supports (valid in any state).

Example:C: a001 CAPABILITYS: * CAPABILITY IMAP4rev1 STARTTLS AUTH=GSSAPI LOGINDISABLEDS: a001 OK CAPABILITY completedC: a002 STARTTLSS: a002 OK STARTLS completed<TLS negotiation, further commands are under [TLS] layer>C: a003 CAPABILITYS: * CAPABILITY IMAP4rev1 AUTH=GSSAPI AUTH=PLAINS: a003 OK CAPABILITY completedC: a004 LOGIN joe passwordS: a004 OK LOGIN completed

Server made client to establish TLS connection. Note: strings beginning with * correspond to the reply with the following tag number.

Page 18: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP4v1 client commands

SELECT: selects a mailbox so that messages in the mailbox can be accessed (valid in Authenticated State).

Example:C: A142 SELECT INBOXS: * 172 EXISTSS: * 1 RECENTS: * OK [UNSEEN 12] Message 12 is first unseenS: * OK [UIDVALIDITY 3857529045] UIDs valid (session ID)S: * OK [UIDNEXT 4392] Predicted next UIDS: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] LimitedS: A142 OK [READ-WRITE] SELECT completed

EXAMINE: the same as SELECT but the selected mailbox is identified as read-only.

Page 19: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP4v1 client commands

CREATE: creates a mailbox with the given name (valid in Authenticated State).

Example:C: A003 CREATE mailbox2/S: A003 OK CREATE completed

DELETE: deletes a mailbox with the given name (valid in Authenticated State).

Example:C: A104 DELETE mailbox2/S: A104 OK DELETE completed

Page 20: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP4v1 client commands

Selected State

CLOSE: removes all messages that have the \Deleted flag set from the currently selected mailbox, and returns to the authenticated state from the selected state.

EXPUNGE: removes all messages that have the \Deleted flag set from the currently selected mailbox.

SEARCH: searches the mailbox for messages that match the given searching criteria.

Example:C: A282 SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith"S: * SEARCH 2 84 882

Page 21: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP4v1 client commands

Selected State

FETCH: retrieves data associated with a message in the mailbox.

STORE: alters data associated with a message in the mailbox.

COPY: copies selected messages to the end of the specified destination mailbox.

Page 22: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP4v1 session example

S: * OK IMAP4rev1 Service ReadyC: a001 login mrc secretS: a001 OK LOGIN completedC: a002 select inboxS: * 18 EXISTSS: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)S: * 2 RECENTS: * OK [UNSEEN 17] Message 17 is the first unseen messageS: * OK [UIDVALIDITY 3857529045] UIDs validS: a002 OK [READ-WRITE] SELECT completedC: a003 fetch 12 fullS: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" "IMAP4rev1 WG mtg summary and minutes" (("Terry Gray" NIL "gray" "cac.washington.edu")) (("Terry Gray" NIL "gray" "cac.washington.edu")) (("Terry Gray" NIL "gray" "cac.washington.edu")) ((NIL NIL "imap" "cac.washington.edu")) ((NIL NIL "minutes" "CNRI.Reston.VA.US") ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL "<[email protected]>") BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 92))S: a003 OK FETCH completed

Page 23: Petrozavodsk State University, Alex Moschevikin, 2003

Petrozavodsk State University, Alex Moschevikin, 2003 NET TECHNOLOGIES

IMAP4v1 session example

C: a004 fetch 12 body[header]S: * 12 FETCH (BODY[HEADER] {342}S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT)S: From: Terry Gray <[email protected]>S: Subject: IMAP4rev1 WG mtg summary and minutesS: To: [email protected]: cc: [email protected], John Klensin <[email protected]>S: Message-Id: <[email protected]>S: MIME-Version: 1.0S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCIIS:S: )S: a004 OK FETCH completedC: a005 store 12 +flags \deletedS: * 12 FETCH (FLAGS (\Seen \Deleted))S: a005 OK +FLAGS completedC: a006 logoutS: * BYE IMAP4rev1 server terminating connectionS: a006 OK LOGOUT completed

As a result, message number 12 was deleted from mailbox.