Top Banner
Application: Electronic Mail Linda Wu (CMPT 471 • 2003-3)
29

Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Application: Electronic Mail

Linda Wu

(CMPT 471 • 2003-3)

Page 2: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 2

Content

Email system model SMTP protocol MIME extensions Mail access protocols

Reference: chapter 27

Page 3: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 3

Email System Model

Client-server model

MTA

MTA

User A (sender) User B (receiver)

MTA

Client ServerRelay Relay

Internet

Alias expanderDB

MTA

DB

Spool

UA

Mailboxes

UA

interface interface

Alias expander

Page 4: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 4

Email System Model (cont.)

UA: user agent A program used by the user to send and

receive emails, e.g., mutt, elm, pine, Eudora, Outlook Express

Sending email The user creates mail through the UA The mail has an envelop and a message

Receiving email UA checks the mailboxes periodically Displays a message list, in which each line is

a summary about a particular message in the mailbox: sender email address, subject, the time the mail was sent or received

Page 5: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 5

Email System Model (cont.)

MAIL FROM: [email protected] TO: [email protected]

From: User ATo: User BReply-to: [email protected]: dd/mm/yyyySubject: ……

Dear User B,……..Yours,User A

Bod

yH

ead

er

Mess

ag

eE

nvelo

p

Page 6: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 6

Email System Model (cont.)

MTA: mail transfer agent The actual mail transfer is done through

MTA Unix MTA: Sendmail, postfix, …… Client MTA is needed to send email Server MTA is needed to receive email

Page 7: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 7

Email System Model (cont.)

Delayed deliveryThe message does not have to be delivered immediately

Sender-side delay: spooling After UA creates a message, the message is

delivered to spool for storage MTA periodically (10~30 mins) checks the

mail in the spool to see if it can be sent If the message cannot be sent, it remains in

the spool to be checked in the next cycle If a message cannot be delivered in the

time-out period (3~5 days), it is returned to the sender

Page 8: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 8

Email System Model (cont.)

Receiver-side delay After the message is received by the MTA,

it does not have to be read the receiver immediately

The mail can be stored in the mailbox of the receiver

Intermediate delay The intermediate MTAs can receive mails,

keep mails in their own mailboxes and spools, and send them when appropriate

Page 9: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 9

Email System Model (cont.)

Email address Email address must be unique Two parts: local-part & domain-name

Local-part @ Domain-name

Address of the mailbox on the destination machine

Domain name of a mail destination to which the mail should be delivered

Page 10: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 10

Email System Model (cont.)

Mail alias expansion One-to-many alias expansion

User can create an alias that is mapped to a list of recipients (mailing list)

The recipients on a list need not to be local For an outgoing message

Check the recipient’s name against the alias expansion database

If there is an expansion, replace the recipient with the mapped version, and pass the message to MTA

Alias is also used to map incoming recipient address

Page 11: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 11

Email System Model (cont.)

Many-to-one alias expansion A user can have several email addresses,

but the user agent only recognizes one mailbox name

When a system receives mail, it checks the many-to-one expansion database

If a mailbox name corresponding to the local part of the received address is found, the mail is sent to that mailbox; otherwise, it is discarded

Page 12: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 12

Email System Model (cont.)

One-to-many alias expanderDB

friends (one name)

usera@ site1.com

userb@ site2.edu

userc@ site1.com

Many-to-one alias expanderDB

John (one recipient)

william@ site1.com

john@ site1.com

black@ site1.com

(many recipients) (many addresses)

Page 13: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 13

Simple Mail Transfer Protocol SMTP

Focuses on how the underlying mail delivery system passes mails across an internet

Does NOT specify: How the mail system accepts mail from a

user How the user interface presents the user

with incoming mail How the mail is stored

Sends mail in NVT 7-bit ASCII format Cannot be used for languages not

supported by 7-bit ASCII characters Cannot send binary data

Page 14: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 14

Simple Mail Transfer Protocol (cont.)

Commands and responses SMTP uses commands and responses to

transfer mail between an MTA client and an MTA server

Command Keyword: argument(s)

Response A 3-digit code that may be followed by

additional textual information

MTA client

MTA server

Commands

Responses

Page 15: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 15

Simple Mail Transfer Protocol (cont.)

Commandskeyword Argument(s) MeaningHELO Sender’s host

nameTo identify the client itself

MAIL FROM

Sender of the message

To identify the sender of the mail

RCPT TO Intended recipient

To identify mail recipient

DATA Body of the mail To send the actual message

QUIT To terminate the message

RSET To abort the current mail transaction

VRFY Name of recipient to be verified

To verify the address of the recipient

NOOP To check the status of the recipient

Page 16: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 16

Simple Mail Transfer Protocol (cont.)

ResponsesCode Meaning

Positive reply

… ……

220 Service ready

221 Service closing transmission channel

250 Requested command completed

251 User not local; mail will be forwarded

354 Start mail input

Negative reply

421 Service not available

450 Mailbox not available

.. ……

500 Syntax error; unrecognized command

.. ……

Page 17: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 17

Simple Mail Transfer Protocol (cont.)

MA

IL F

RO

M:

use

ra@

site

1.c

om

25

0 O

K

RC

PT T

O:

use

r2@

site

2.e

du

25

0 O

K

DA

TA

35

4 s

tart

mail

inp

ut

From

: U

ser

A

To:

Use

r B

Date

: d

d/m

m/y

yyy

Su

bje

ct:

……

(Em

pty

lin

e)

Dear

use

r B

,

…..

.

.

25

0 O

K

MTA

cl

ien

t

MTA

se

rver

Envelop Header Body

Page 18: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 18

Simple Mail Transfer Protocol (cont.)

Mail transfer The process of transferring a mail has 3

phases Connection establishment Mail transfer Connection termination

Page 19: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 19

Simple Mail Transfer Protocol (cont.)

Email transfer connection establishment

MTA server

220 service ready

TCP 25MTA client TCP XXXXX

250 OK

HELO: site1.com

221 service closed

QUIT

… mail transfer …

Email transfer connection termination

TCP connection

ready

Page 20: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 20

MIME Extensions

Multipurpose Internet Mail Extensions A supplementary protocol that allows non-

ASCII data to be sent through SMTP Not a mail protocol; only an extension to

SMTP Can be thought of as a set of software

functions that transform non-ASCII data to ASCII data and vice versa

MIME

User A

SMTP

MIME

User B

SMTP

Non-ASCII

7-bit NVT ASCII

Non-ASCII

7-bit NVT ASCII7-bit NVT ASCII

Page 21: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 21

MIME Extensions (cont.)

MIME headers MIME defines 5 headers to be added to

the original SMTP header section The headers define the transformation

parameters MIME-Version: current version is 1.1 Content-Type: text/plain, image/jpeg,

image/gif, multipart/mixed, application/postscript, ……

Content-Transfer-Encoding: 7bit, 8bit, binary, base64, quoted-printable

Content-Id: uniquely identify the message Content-Description

Page 22: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 22

MIME Extensions (cont.)

Email header

MIME-Version: 1.1Content-Type: type/subtypeContent-Transfer-Encoding: encoding typeContent-Id: message idContent-Description: textual explanation of nontextual contents

MIME header

Email body

Page 23: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 23

MIME Extensions (cont.)

Base64 encoding Divide the binary data into 24-bit blocks Each blocks is then divided into four 6-bit

sections Interpret each 6-bit section as one

character according to Base64 encoding table

Non-ASCII data 11001100 10000001 00111001

110011 (51)

001000 (8)

000100 (4)

111001 (57)

ASCII data 01110011 01001000 01000100 00111001

Z I E 5

Page 24: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 24

MIME Extensions (cont.)

Quoted-printable encoding If a character is ASCII, it is sent as it is If a character is not ASCII, it is sent as 3

characters: The first character is “=” The next two are the hexadecimal

representation of the byte

00100110 &

01001100 L

10011101 Non-ASCII

00111001 9

01001011 K

00100110 &

01001100 L

00111101 =

00111001 9

01000100 D

00111001 9

01001011 K

Mixed ASCII & non-ASCII data

ASCII data

Page 25: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 25

Mail Access Protocols

Mail delivery

SMTP client

Local SMTP server

Remote SMTP server

Mail box

Mail access server

Mail access client

Stage 1

(SMTP)

Stage 2

(SMTP)

Stage 3

(Mail Access Protocol)

Page 26: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 26

Mail Access Protocols (cont.)

Mail is stored in user’s permanent mailbox for later retrieval

Mail access protocol To retrieve mails from a permanent

mailbox to a local computer To manipulate the mailbox content Two popular mail access protocols

Post Office Protocol Version 3 (POP3) Internet Mail Access Protocol Version 4

(IMAP4)

Page 27: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 27

Mail Access Protocols (cont.)

POP3 POP3 client creates a TCP connection to

the POP3 server on the mailbox computer

Server authenticates the session using user-name and password

Client sends commands to retrieve a copy of one or more messages

Two modes Delete mode: the mail is deleted from the

mailbox after each retrieval Keep mode: the mail remains in the

mailbox after retrieval

Page 28: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 28

Mail Access Protocols (cont.)

POP3 server

User-name

TCP 110POP3 client

TCP XXXXX

Password

OK

Email 1

Retrieve 1

User computer Mail server

OK

Email # and sizes

List

……

Email N

Retrieve N

Page 29: Application: Electronic Mail Linda Wu (CMPT 471 2003-3)

Notes-19 CMPT 471 2003-3 29

Mail Access Protocols (cont.)

IMAP4 Similar functions as POP3

Mailboxes are located on the same computer as IMAP4 server

User runs IMAP4 client to contact the server and retrieve mails

Extended functions A user can check the email header, or, search

the contents of the mails for a specific string, before downloading

A user can partially download mail A user can create, delete, or remove

mailboxes on the mail server A user can create a hierarchy of mailboxes in

a folder for email storage