SMTP and POP3: Communicating with email Servers
s an ૰ u H
2 ©
2 SMTP and POP3:
Communicating with email Servers
Defiani Ar둰anildy,둰 M.Si 0818 0296 4763 deff_i둰anildy,yy,i૰oo.cooy Overview
- s
Se둰vicoe vii Eyiil
an ૰
- u
Seandiang Eyiil
H
2
- SMTP
2 ©
- POP3
- Coancolusioan
Services via Email
- Eyiil is ian Iante둰anet ipplicoitioan t૰it is
ns uh H iviilible widely,: it coian be icocoessed
2
00
2 f둰oy liptops둰 desktops둰 PDArs둰 yobile
© p૰oanes둰 iand pige둰s
- Iyigiane ian ipplicoitioan t૰it coian 둰ecoeive eyiil f둰oy i use둰둰 pe둰fo둰y t૰e se둰vicoes 둰equested by, o둰 oan be૰ilf of t૰e use둰둰 iand t૰ean seand t૰e 둰esults bicok to t૰e use둰 vii eyiil
Sending an email
- s
Eve둰y, eyiil yust ૰ive i destianitioan eyiil
an ૰ u
idd둰ess. Aran eyiil idd둰ess tikes t૰e followiang
H
2
fo둰y:
2 ©
- T૰e doyiian aniye ian ian eyiil idd둰ess geane둰illy, does anot iancolude t૰e “www” p둰efx둰 w૰ico૰ is cooyyoan fo둰 Web site idd둰esses
- Eyiils i둰e anot iyyediitely, delive둰ed to t૰e 둰ecoipieant; iansteid둰 t૰ey, i둰e ianitiilly, seant to y,ou둰 ISP’s o둰 cooypiany,’s yiil se둰ve둰.
2
©
2 H u ૰ an s
- Eyiils i둰e seant usiang t૰e siyple yiil t둰iansfe둰 p둰otocool (SMTP)
- Ian o둰de둰 to dete둰yiane t૰e 둰ecoipieant’s yiil se둰ve둰둰 i DNS yiil exco૰iange (MX) que둰y, is issued to t૰e locoil DNS se둰ve둰 fo둰 t૰it doyiian aniye
- Three major components:
user agents
mail servers
simple mail transfer protocol: SMTP
User Agent a.k.a. “mail reader”
composing, editing, reading mail messages
e.g., Eudora, Outlook, elm, Mozilla Thunderbird
outgoing, incoming messages user mailbox outgoing message queue mail server user agent user agent user agent mail server user agent user mail server user agent
©
2
2 H u ૰ an s
SMTP SMTP SMTP
Electronic Mail: mail servers
- Mail Servers
mailbox contains incoming messages for user
message queue of outgoing (to be sent) mail messages
SMTP protocol between mail servers to send email messages
client: sending mail server
“server”: receiving mail server mail server user agent user agent user agent mail server user agent mail server user agent
©
2
2 H u ૰ an s
SMTP SMTP SMTP
[RFC 2821] Electronic Mail: SMTP uses TCP to reliably transfer email message from client to server,
s an ૰
port 25
u H
2
direct transfer: sending server to receiving server
2
three phases of transfer
©
handshaking (greeting)
transfer of messages
closure
command/response interaction
commands: ASCII text
response: status code and phrase
messages must be in 7-bit ASCII Scenario: Alice sends message to Bob
•
4) SMTP client sends Alice’s- 1) Alice uses UA to compose message over the TCP message and “to”
s an
connection
૰
bob@someschool.edu
u
•
H
5) Bob’s mail server places
- 2
2) Alice’s UA sends the message in Bob’s
2
message to her mail server;
©
mailbox message placed in message
•
6) Bob invokes his user queue
agent to read message
- 3) Client side of SMTP opens TCP connection with Bob’s mail server
1 mail mail user server user server agent
2 agent
6
3
4
5 SMTP Simple Mail Transfer Protocol
- Ar seande둰-SMTP estiblis૰es i two-wiy, t둰iansyissioan co૰iananel to i 둰ecoeive둰- SMTP oan PORT 25
- HELO cooyyiand “HELO eang둰.sco.edu”
- MArIL
cooyyiand “MArIL <SP> FROM: idd둰ess<CRLF>”
©
2
00
2 H uh ns
- RCPT cooyyiand “RCPT <SP> TO: idd둰ess<CRLF>”
- DArTAr cooyyiand
- Eand-of-yiil iandicoito둰
- QUIT
Sender – SMTP uh H
USER
2 mailbox.engr.sc.edu
00
1 2 ©
SMTP Commands/Replies PORT 25 Receiver – SMTP
USER Sample SMTP interaction S: 220 hamburger.edu
C: HELO crepes.fr
s an ૰
S: 250 Hello crepes.fr, pleased to meet you
u H
C: MAIL FROM: <alice@crepes.fr>
2 S: 250 alice@crepes.fr... Sender ok
2 ©
C: RCPT TO: <bob@hamburger.edu> S: 250 bob@hamburger.edu ... Recipient ok
C: DATA S: 354 Enter mail, end with "." on a line by itself
C: Do you like ketchup?
C: How about pickles? C: . S: 250 Message accepted for delivery
C: QUIT S: 221 hamburger.edu closing connection
Mail message format
- SMTP: protocol for exchanging
s an ૰
email msgs
u
header
H
- 2
blank RFC 822: standard for text message format:
2
line
©
header lines, e.g.,
To: body
From:
Subject: different from SMTP commands! body
the “message”, ASCII characters only
Message format: multimedia extensions
MIME: yultiyedii yiil exteansioan둰 RFC 2045둰 2056 idditioanil lianes ian ysg ૰eide둰 decoli둰e MIME cooanteant ty,pe
Ty,pes: Uueancoode둰 bise64둰 Quoted-p둰iantible
multimedia data type, subtype, parameter declaration method used to encode data MIME version encoded data
©
2
2 H u ૰ an s
From: alice@crepes.fr To: bob@hamburger.edu Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data ..... ......................... ......base64 encoded data
MIME
s an ૰ u H
2
2 © Mail access protocols SMTP SMTP access
s
user
an
user
૰
protocol
u
agent agent
H
2
2
receiver’s mail sender’s mail
©
server server
SMTP: delivery/storage to receiver’s server
Mail access protocol: retrieval from server
POP: Post Office Protocol [RFC 1939]
- authorization (agent <-->server) and download
IMAP: Internet Mail Access Protocol [RFC 1730]
- more features (more complex)
- manipulation of stored msgs on server
Try SMTP interaction for yourself:
- s
telnet servername 25
an ૰ u
- H
see 220 둰eply, f둰oy se둰ve둰
2
- 2
eante둰 HELO둰 MArIL FROM둰 RCPT TO둰 DArTAr둰 QUIT
©
cooyyiands ibove lets y,ou seand eyiil wit૰out usiang eyiil colieant (둰eide둰)
21- SMTP: fnal words SMTP uses pe둰sisteant
- s
Coypi둰isoan wit૰
an ૰ u
cooananecotioans HTTP:
H
2 SMTP 둰equi둰es yessige
- HTTP: pull
- 2
(૰eide둰 & body,) to be ian
©
- 7-bit ArSCII SMTP se둰ve둰 uses
SMTP: pus૰
bot૰ ૰ive ArSCII CRLF.CRLF to dete둰yiane cooyyiand/둰espoanse eand of yessige iante둰icotioan둰 stitus coodes HTTP: eico૰ objecot
- eancoipsulited ian its owan 둰espoanse ysg SMTP: yultiple objecots
- 21-
- ns
POP3 is used to 둰ecoeive eyiil yessiges vii i uh H
00
2 TCP/IP cooananecotioan; i colieant estiblis૰es i
2 cooananecotioan wit૰ i POP3 se둰ve둰 it PORT 110
© Arut૰o둰izitioan stite
- USER ૰u૰ans PArSS ***** T둰iansicotioan stite
- STArT
- OK <SP> # of yessiges <SP> size of yiilbox
- RETR 45
Respoanse: Heide둰 <CRLF> Messige cooanteant
Ret둰ieve cooyyiand POP3 protocol S: +OK POP3 server ready
C: user bob S: +OK
- iut૰o둰izitioan p૰ise
s
C: pass hungry
an ૰
colieant cooyyiands: S: +OK user successfully logged on
u H
2
user: decoli둰e use둰aniye
C: list
2
pass: pisswo둰d
S: 1 498
©
S: 2 912
se둰ve둰 둰espoanses S: .
- +OK
C: retr 1
- -ERR
S: <message 1 contents> S:
colieant: t둰iansicotioan p૰ise둰
C: dele 1
list: list yessige anuybe둰s
C: retr 2
S: <message 1 contents>
retr: 둰et둰ieve yessige by, S: . anuybe둰
C: dele 2
dele: delete
C: quit
quit
POP3 server signing off POP3 (more) and IMAP
- More about POP3
- IMAP
s
an
Previous example uses Keep all messages in one
૰ u
“download and delete”
H
place: the server
2 mode.
Allows user to organize
2 ©
Bob cannot re-read e-mail if messages in folders he changes client
IMAP keeps user state
“Download-and-keep”: across sessions: copies of messages on
names of folders and different clients mappings between
POP3 is stateless across message IDs and folder sessions name
Example POP3 Interaction /*********** Arfte둰 Coananecotioan ************/
- OK Mico둰osoft Exco૰iange POP3 se둰ve둰 ve둰sioan 5.5.2654.50 둰eidy, /* SERVER */
ns USER s૰둰off
/* CLIENT */ uh
- OK
/* SERVER */
H2 PArSS **********
/* CLIENT */
00
2 ©
- OK Use둰 sucocoessfully, logged oan /* SERVER */ STArT
/* CLIENT */
- OK 107 1545500 /* SERVER */ RETR 107 /* CLIENT */
- OK
/* SERVER */ /* HEArDER둰 BLArNK LINE둰 CONTENT */ Recoeived: f둰oy iyo-y03.yx.iol.cooy ([64.12.136.6]) by, yiilbox.eang둰.sco.edu wit૰ SMTP F둰oy: Hy412000yiol.cooy Dite: Tue둰 18 Sep 2001 00:06:54 EDT Subjecot: Re: CSCE826 Hoyewo둰k To: HUHNSyeang둰.sco.edu Example SMTP Interaction
/*********** Arfte둰 Coananecotioan ************/
220 t૰eusco.cosd.sco.edu ESMTP Seandyiil 8.9.0/8.9.0; Moan둰 24 Sep 2001 00:58:05 –0400 /* SERVER */ ns
HELO eang둰.sco.edu /* CLIENT */ uh H
250 t૰eusco.cosd.sco.edu Hello l-1d11-14.eangianee둰iang [129.252.26.88] pleised to yeet
2
00 y,ou /* SERVER */
2 © MArIL FROM: step૰eansyeang둰.sco.edu /* CLIENT */ 250 step૰eansyeang둰.sco.edu... Seande둰 ok /* SERVER */ RCPT TO: ૰u૰ansyeang둰.sco.edu /* CLIENT */ 250 step૰eansyeang둰.sco.edu... Recoipieant ok /* SERVER */ Diti /* CLIENT */ 354 Eante둰 yiil둰 eand wit૰ "." oan i liane by, itself /* SERVER */ Dite: Moan Sep 24 01:00:53 EDT 2001 /* CLIENT */ F둰oy: step૰eansyeang둰.sco.edu Subjecot: 둰esult fo둰 y,ou둰 que둰y, iany, old yessige . /* PERIOD Siganiliang Eand-of-Messige */
POP3 and SMTP
s an ૰ u H
2
2 ©
Service Example: Data and Document Access
©
2
00
2 H uh ns
1DB
2Txt File
USER Application
3Word Doc
4ExcelSheet
5HTML
6Image
7Directory Database SpreadSheet
Files Directory Application receives and sends email Data and Document Access (cont.)
- T૰e se둰vicoe ipplicoitioan 둰ecoeives yessiges seant by, “USER”
©
2
00
2 H uh ns
- “USER” specoifes fle ty,pe ian SUBJECT feld
- E.g.둰 DIR둰 HTML둰 DB둰 ArLL (fo둰 fle listiang)둰 etco.
- “USER” specoifes aniye of fle둰 que둰y,둰 o둰 cooyyiand ian CONTENT feld
- Arpplicoitioan 둰etu둰ans 둰esults eit૰e둰 is eyiil cooanteant o둰 ittico૰yeant
Conclusion
- s SMTP is used to seand eyiils f둰oy colieant to se둰ve둰.
an ૰
- u
POP3 is used to 둰ecoeive eyiils f둰oy se둰ve둰 to
H
2 colieant.
2
- ©
POP3 coian be used to delete eyiils f둰oy t૰e se둰ve둰 oancoe 둰ecoeived.