Internet Engineering Course

62
Internet Engineering Internet Engineering Course Course Electronic Mail

description

Internet Engineering Course. Electronic Mail. Electronic Mail. Most heavily used application on any network Uses client-server architecture Electronic mail client accepts mail from user and delivers to server on destination computer Many variations and styles of delivery - PowerPoint PPT Presentation

Transcript of Internet Engineering Course

Page 1: Internet Engineering Course

Internet Engineering Internet Engineering CourseCourse

Electronic Mail

Page 2: Internet Engineering Course

Electronic MailElectronic MailMost heavily used application on any

networkUses client-server architecture

◦ Electronic mail client accepts mail from user and delivers to server on destination computer

◦ Many variations and styles of deliverySimple Mail Transfer Protocol (SMTP)

◦ TCP/IP◦ Delivery of simple text messages

Multi-purpose Internet Mail Extension (MIME)◦ Delivery of other types of data◦ Voice, images, video clips

Page 3: Internet Engineering Course

SMTP ConceptSMTP Concept

Page 4: Internet Engineering Course

User Agents and Mail Transfer AgentsUser Agents and Mail Transfer Agents

Page 5: Internet Engineering Course

Relay MTAsRelay MTAs

Page 6: Internet Engineering Course

Mail GatewaysMail Gateways

Page 7: Internet Engineering Course

The Entire E-mail SystemThe Entire E-mail System

Page 8: Internet Engineering Course

SMTPSMTPSimple Mail Transfer Protocol is

standard application protocol for delivery of mail from source to destination

Built on top of TCP: provides reliable delivery of data

SMTP does not normally use intermediate mail servers for sending mail

SMTP uses persistent connectionsOther functions:

◦E-mail address lookup◦E-mail address verification

Example protocol exchange

Page 9: Internet Engineering Course

Sample SMTP interactionSample SMTP interaction c:\Telnet payk.ui.ac.ir 25

Page 10: Internet Engineering Course
Page 11: Internet Engineering Course

SMTPSMTPRFC 821Not concerned with format of

messages or data◦Covered in RFC 822 (see later)

SMTP uses info written on envelope of mail ◦Message header

Does not look at contents ◦Message body

Except:◦Standardize message character set to 7 bit

ASCII

Page 12: Internet Engineering Course

Basic OperationBasic OperationMail created by user agent

program (mail client)◦Message consists of:

Header containing recipient’s address and other info

Body containing user data

Messages queued and sent as input to SMTP sender program◦Typically a server process (daemon

on UNIX)

Page 13: Internet Engineering Course

Mail Message ContentsMail Message ContentsEach queued message has:

◦Message text RFC 822 header with message envelope and

list of recipients Message body, composed by user

◦A list of mail destinations Derived by user agent from header May be listed in header May require expansion of mailing lists May need replacement of mnemonic names

with mailbox namesIf BCCs indicated, user agent needs

to prepare correct message format

Page 14: Internet Engineering Course

SMTP SenderSMTP SenderTakes message from queueTransmits to proper destination host

◦Via SMTP transaction◦Over one or more TCP connections to port

25Host may have multiple senders activeWhen delivery complete, sender

deletes destination from list for that message

When all destinations processed, message is deleted

Page 15: Internet Engineering Course

OptimizationOptimizationIf message destined for multiple

users on a given host, it is sent only once◦Delivery to users handled at

destination hostIf multiple messages ready for

given host, a single TCP connection can be used◦Saves overhead of setting up and

dropping connection

Page 16: Internet Engineering Course

Possible ErrorsPossible ErrorsHost unreachableHost out of operationTCP connection fail during transferSender can re-queue mail

◦Give up after a periodFaulty destination address

◦User error◦Target user changed address◦Redirect if possible◦ Inform user if not

Page 17: Internet Engineering Course

SMTP Protocol - Reliability SMTP Protocol - Reliability Used to transfer messages from

sender to receiver over TCP connectionAttempts to provide reliable serviceNo guarantee to recover lost messagesNo end to end acknowledgement to

originatorError indication delivery not

guaranteedGenerally considered reliable

Page 18: Internet Engineering Course

SMTP ReceiverSMTP ReceiverAccepts arriving messagePlaces in user mailbox or copies to

outgoing queue for forwardingReceiver must:

◦Verify local mail destinations◦Deal with errors

Transmission Lack of disk space

Sender responsible for message until receiver confirm complete transfer◦ Indicates mail has arrived at host, not

user

Page 19: Internet Engineering Course

SMTP ForwardingSMTP ForwardingMostly direct transfer from

sender host to receiver hostMay go through intermediate

machine via forwarding capability◦Sender can specify route◦Target user may have moved

Page 20: Internet Engineering Course

ConversationConversationSMTP limited to conversation

between sender and receiverMain function is to transfer

messagesRest of mail handling beyond

scope of SMTP◦May differ between systems

Page 21: Internet Engineering Course

SMTP Mail FlowSMTP Mail Flow

Page 22: Internet Engineering Course

SMTP System OverviewSMTP System OverviewCommands and responses between

sender and receiverInitiative with sender

◦Establishes TCP connectionSender sends commands to receivere.g. HELO<SP><domain><CRLF>Each command generates exactly one

replye.g. 250 requested mail action ok;

completed

Page 23: Internet Engineering Course

SMTP RepliesSMTP RepliesLeading digit indicates category

◦Positive completion reply (2xx)◦Positive intermediate reply (3xx)◦Transient negative completion reply

(4xx)◦Permanent negative completion

reply (5xx)

Page 24: Internet Engineering Course

Operation PhasesOperation PhasesConnection setupExchange of command-response

pairsConnection termination

Page 25: Internet Engineering Course

Connection SetupConnection SetupSender opens TCP connection with

receiverOnce connected, receiver identifies

itself◦220 <domain> service ready

Sender identifies itself◦HELO

Receiver accepts sender’s identification◦250 OK

If mail service not available, step 2 above becomes:◦421 service not available

Page 26: Internet Engineering Course

Mail TransferMail TransferSender may send one or more

messages to receiverMAIL command identifies originator

◦Gives reverse path to used for error reporting

◦Receiver returns 250 OK or appropriate fail/error message

One or more RCPT commands identifies recipients for the message◦Separate reply for each recipient

DATA command transfers message text◦End of message indicated by line containing

just period (.)

Page 27: Internet Engineering Course

Closing ConnectionClosing ConnectionTwo stepsSender sends QUIT and waits for

replyThen initiate TCP close operationReceiver initiates TCP close after

sending reply to QUIT

Page 28: Internet Engineering Course

Electronic Mailboxes and Electronic Mailboxes and AddressesAddressesE-mail users have an electronic

mailbox into which mail is deposited

Usually associated with computer account; one user may have different electronic mailboxes

User accesses mail with a mail reader program

Electronic mailbox is identified by an e-mail address

mailbox@computer

Page 29: Internet Engineering Course

E-mail message formatE-mail message formatSimple two-part format

◦Header includes delivery information◦Body carries text of message

Header and body is separated by blank line

Page 30: Internet Engineering Course

E-mail HeadersE-mail HeadersLines of text in format keyword:

informationkeyword identifies information;

information can appear in any orderEssential information:

◦To: list of recipients◦From: sender◦Cc: list of copy recipients

Useful information◦Reply-to: different address than From:◦Received-by: for debugging

Frivolous information:◦Favorite drink: lemonade◦Phase-of-the-moon: gibbous

Page 31: Internet Engineering Course

Data in E-mailData in E-mailOriginal Internet mail carried only 7-

bit ASCII dataCouldn’t contain arbitrary binary

values; e.g., executable programTechniques for encoding binary data

allowed transport of binary dataUuencode: three 8-bit binary values

as four ASCII characters (6 bits each)◦Also carries file name and protection

information◦ Incurs 33% overhead

Page 32: Internet Engineering Course

Multipurpose Internet Mail Multipurpose Internet Mail Extension (MIME)Extension (MIME)Extension to RFC822SMTP can not transmit executables

◦ Uuencode and other schemes are available Not standardized

Can not transmit text including international characters (e.g. â, å, ä, è, é, ê, ë)◦ Need 8 bit ASCII

Servers may reject mail over certain sizeTranslation between ASCII and EBCDIC not

standardSome SMTP implementations do not adhere to

standard◦ CRLF, truncate or wrap long lines, removal of white

space, etc.

Page 33: Internet Engineering Course

MIMEMIMEMultipart Internet Mail Extensions -

Extends and automates encoding mechanisms

Allows inclusion of separate components – programs, pictures, audio clips – in a single mail message

Sending program identifies the components so receiving program can automatically extract and inform mail recipient◦ Header includes

MIME-Version: 1.0Content-Type: Multipart/Mixed; Boundary=Mime_separator

◦ Separator line gives information about specific encodingContent-Type: text/plain

Page 34: Internet Engineering Course

MIME (cont.)MIME (cont.)MIME is extensible – sender and

receiver agree on encoding scheme

MIME is compatible with existing mail systems◦Everything encoded as ASCII◦Headers and separators ignored by

non-MIME mail systemsMIME encapsulates binary data in

ASCII mail envelope

Page 35: Internet Engineering Course

MIME

Page 36: Internet Engineering Course

Overview of MIMEOverview of MIMEFive new message header fields

◦MIME version◦Content type◦Content transfer encoding◦Content Id◦Content Description

Page 37: Internet Engineering Course

Content TypesContent Types Text body Multipart

◦ Mixed, Parallel, Alternative, Digest Message

◦ RFC 822, Partial, External-body Image

◦ jpeg, gif Video

◦ mpeg Audio

◦ Basic Application

◦ Postscript◦ octet stream

Page 38: Internet Engineering Course

MIME Transfer EncodingsMIME Transfer EncodingsReliable delivery across wide largest range of

environmentsContent transfer encoding field

◦ Six values◦ Three (7bit, 8bit, binary) no encoding done

Provide info about nature of dataQuoted-printable

◦ Data largely printable ASCII characters◦ Non-printing characters represented by hex code

Base64◦ Maps arbitrary binary input onto printable output

X-token◦ Named nonstandard encoding

Page 39: Internet Engineering Course

Message format: multimedia Message format: multimedia extensionsextensions MIME: multimedia mail extension, RFC 2045, 2056 additional lines in msg header declare MIME content

type

From: [email protected] To: [email protected] Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg

base64 encoded data ..... ......................... ......base64 encoded data

multimedia datatype, subtype,

parameter declaration

method usedto encode data

MIME version

encoded data

Page 40: Internet Engineering Course

2: Application Layer

Multipart TypeMultipart Type

From: [email protected] To: [email protected] Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=98766789 --98766789Content-Transfer-Encoding: quoted-printableContent-Type: text/plain

Dear Bob, Please find a picture of a crepe.--98766789Content-Transfer-Encoding: base64Content-Type: image/jpeg

base64 encoded data ..... ......................... ......base64 encoded data --98766789--

Compare with HTTP?

Break into parts?

Page 41: Internet Engineering Course

Printable Encoding of Binary Data Printable Encoding of Binary Data into Radix-64 Formatinto Radix-64 Format

Page 42: Internet Engineering Course

Programs as mail Programs as mail recipientsrecipientsCan arrange for e-mailbox to be

associated with a program rather than a user’s mail reader

Incoming mail automatically processed as input to program

Example – mailing list subscription administration

Can be used to implement client-server processing◦Client request in incoming mail

message◦Server response in returned mail reply

Page 43: Internet Engineering Course

Mailing Lists and Mailing Lists and ForwardersForwardersE-mail addresses can be attached

to programs as well as electronic mailboxes

Mail exploder or mail forwarder resends copies of message to e-mail addresses in mailing list◦UNIX mail program sendmail

provides mail aliases◦Mailing list processor, e.g. listserv,

can also interpret subscription management commands

Page 44: Internet Engineering Course

Mail GatewaysMail GatewaysMailing list processing may take

significant resources in large organizations

May be segregated to a dedicated server computer: mail gateway◦Provides single mail destination point

for all incoming mail◦Can use MX records in DNS to cause

all mail to be delivered to gateway

Page 45: Internet Engineering Course

Mail gateways and Mail gateways and forwardingforwardingUsers within an organization may

want to read mail on local or departmental computer

Can arrange to have mail forwarded from mail gateway

Message now makes multiple hops for delivery

Hops may be recorded in headerForwarded mail may use

proprietary (non-SMTP) mail system

Page 46: Internet Engineering Course

Mailbox AccessMailbox AccessWhere should mailbox be located?Users want to access mail from most

commonly used computerCannot always use desktop computer

as mail server◦ Not always running◦ Requires multitasking OS◦ Requires local disk storage

Can TELNET to remote computer with mail server

Can use WEB based interfaces to access mailbox

Page 47: Internet Engineering Course

Mail Access ProtocolsMail Access Protocols

Instead of TELNET, use protocol that accesses mail on remote computer directly

Mail access protocol transfers mail from server to local PC

2 popular protocols:◦POP3 (Post Office Protocol v3)◦IMAP (Internet Mail Access Protocol)

Can’t use SMTP because getting messages is a pull operation & SMTP is a push protocol.

Page 48: Internet Engineering Course

Post Office Protocol (POP)Post Office Protocol (POP)TCP/IP suite includes Post Office

Protocol (POP) for remote mailbox access◦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)◦Local computer uses SMTP for outgoing

mail

Page 49: Internet Engineering Course

POP3 and SMTP

Page 50: Internet Engineering Course

POP3POP3Stands for Post Office Protocol –

Version 3RFC in 1993POP3 “is intended to permit a

workstation to dynamically access a maildrop on a server host in a useful fashion. Usually, this means that the POP3 protocol is used to allow a workstation to retrieve mail that the server is holding for it.“

Page 51: Internet Engineering Course

POP3POP3Doesn’t provide extensive mail

operations on the serverNormally mail is downloaded, then

deletedDeletion doesn’t really occur until

QUITUses port 110

Page 52: Internet Engineering Course

POP3POP3

Three phases◦Authorization◦Transaction◦Update

During a POP3 session, the server maintains state information

POP3 downloads mail messages to the local machine – not good for “nomadic user”

Page 53: Internet Engineering Course

POP3 protocolPOP3 protocol

authorization phase client commands:

◦ user: declare username◦ pass: password

server responses◦ +OK◦ -ERR

transaction phase, client: list: list message

numbers retr: retrieve message by

number dele: delete quit

C: list S: 1 498 S: 2 912 S: . C: retr 1 S: <message 1 contents> S: . C: dele 1 C: retr 2 S: <message 1 contents> S: . C: dele 2 C: quit S: +OK POP3 server signing off

S: +OK POP3 server ready C: user bob S: +OK C: pass hungry S: +OK user successfully logged on

Page 54: Internet Engineering Course

Dialup Access and POPDialup Access and POPPOP is useful for dialup

connection◦User’s computer not always

connected◦Can download all mail at once and

read off-line◦Can compose mail off-line and mail

in one connection

Page 55: Internet Engineering Course

Minimal POP3 CommandsMinimal POP3 CommandsUSER name – user’s namePASS string – user’s passwordQUIT – quits, and updates the mailboxSTAT – statusLIST [msg] – lists the mail messages (#’s

only)RETR msg – retrieves a mail messageDELE msg – deletes a messageNOOP – No operationRSET – resets the mail to its original state

Page 56: Internet Engineering Course

IMAPIMAPInternet Mail Access ProtocolAllows users to manipulate remote

mailboxesMust maintain info about user (e.g.,

folder hierarchy) even after the user quitsIMAP server is always in 1 of 4 states:

◦Nonauthenticated◦Authenticated◦Selected◦Logout

Page 57: Internet Engineering Course

POP3 (more) and IMAPPOP3 (more) and IMAPMore about POP3Previous example

uses “download and delete” mode.

Bob cannot re-read e-mail if he changes client

“Download-and-keep”: copies of messages on different clients

POP3 is stateless across sessions

IMAPKeep all messages in

one place: the serverAllows user to

organize messages in folders

IMAP keeps user state across sessions:◦ names of folders and

mappings between message IDs and folder name

Page 58: Internet Engineering Course

SecuritySecuritySMTP, POP3 and IMAP are plain

text protocolsSecured version available to

protect the user◦SMTPS◦POP3s◦Need to be configured both on server

and client

Page 59: Internet Engineering Course

StunnelStunnel

Name of an application/service◦Even if the mail server application

does not implement secure versionWhat does it do?

◦gathers the encrypted message from client

◦Decrypts the data◦Sends plain text data using a local

connection to insecure port Server application considers it a normal

client

Page 60: Internet Engineering Course

STunnelingSTunneling

Server Client

Stunnel(on server)Listening to port 995

Send decrypted data to port 25 of the server

Encrypted data(Command/mail body)

Page 61: Internet Engineering Course

Web interfaceWeb interface

Nowadays there are many web interface user agents

They allow accessing messages from any client with only a web browser

However the interface is not as sophisticated as special mail agents

But it is very useful if you need to check your emails from different computers

Page 62: Internet Engineering Course

Summary for EmailSummary for Email

Electronic mail allows quick, asynchronous communication across entire Internet

Can attach e-mail addresses to programs for processing◦ Mailing lists◦ Other client-server applications

Simple Mail Transfer Protocol (SMTP) is Internet standard for mail delivery

Mail gateways◦ Provide uniform user addressing outside organizations◦ Translate from Internet mail (e.g. SMTP) to proprietary

systemsPost Office Protocol (POP) and Internet Mail

Access Protocol (IMAP) allow remote access to electronic mailboxes.