Tải bản đầy đủ - 0 (trang)
Chapter 26. Internet Mail Protocols: POP3, SMTP, and IMAP

Chapter 26. Internet Mail Protocols: POP3, SMTP, and IMAP

Tải bản đầy đủ - 0trang

theserver.IMAPalsoenablestheusertocreatefolderson

theserverthatcanbeusedtostoremessages.This

protocolisoftenreferredtoasIMAP4,becauseitisthe

fourthversionoftheprotocol.

Inthischapter,you'lllearnaboutthebasicfunctionsprovided

bythesethreeprotocols.



Note

Inadditiontothemailprotocolsdiscussedinthis

chapter,youcanuseanHTMLinterfacewithmost

emailproviders.Thisenablesyoutocheckemail

withoutusingamailclient,suchasOutlookExpress.

Instead,youcanentertheURLforyourmailserver

andexamine,read,reply,anddeletemailusingWeb

pagesthattheserverhasdynamicallygenerated.

FormoreinformationaboutHTML(andHTTP),see

Chapter32,"TheHypertextTransferProtocol."







HowSMTPWorks

Asanapplicationprotocol,SMTPreliesontheerror-detection

andcorrectionmechanismsoftheunderlyingtransport

protocolsanddoesnotimplementthesesortsoffunctionsin

theSMTPprotocol.Forexample,TCPusessequencenumbersto

keeptrackofTCPsegmentssentandacknowledged.Thosethat

arenotacknowledgedwithinatimelyfashionareretransmitted.

Thus,SMTP,usingTCPasatransportprotocol,doesn'thaveto

worryaboutthissortofthing.SMTPhasalsobeenimplemented

usingothertransferprotocols,includingNCP,NITS,andX.25.

Forpurposesofthistext,IwillbefocusingonSMTPusingthe

TCPTransportservice,becausethatisthemostcommonmodel

youarelikelytosee.BecauseSMTPisanapplicationprotocol,

it'sassociatedwithaportnumberjustlikeFTP,Telnet,and

otherapplicationsthatmakeuptheTCP/IPsuite.Theport

generallyusedforSMTPisTCPport25.



Note

SMTPwasfirstdefinedbyRFC821,butithasbeen

supercededbyRFC2821,"SimpleMailTransfer

Protocol."AdditionalRFCdocumentshaveadded

functionalitytotheprotocol.Forexample,RFC3207,

"SMTPServiceExtensionsforSecureSMTPover

TransportLayerSecurity."ThisRFCprovidesforboth

authenticationandencryptionforthetransferof

email,basedonTLS.TLSisbasicallyanupgradeto

theSecureSocketsLayer(SSL)securityusedby

manyWebbrowsers.Formoreinformationonthese

securityprotocols,seeChapter47,"Encryption

Technology."



Tip

Whentestinganemailrelay,youmightwanttouse

thetelnetcommandandtheport.Thiscanbedone

byopeningacommandpromptorterminalsession

andconnectingtotherelayviaport25or110.If

youcanconnectandruncommands,youremail

relayisupandfunctional.Thesyntaxforthistestis

Telnet



or

Telnet10.1.1.125

Telnet10.1.1.1110



Onceconnected,youcanruncommandssuchas

HELO,andsoon.



SMTPisusedtosendemailfromaclienttoanSMTPserverand

forSMTPserverstoexchangemail.Otherprotocols,suchas

POP3andIMAP,areusedbyclientstoretrievemailfrom

mailboxesthatresideonSMTPservers.SMTPisnotusedfor

thatpurpose,asyoucanseeinFigure26.1.



Figure26.1.SMTPisusedtosendandreceive



email.SMTPisusedprimarilytouploademailto

theserver,whereasPOP3isgenerallyusedto

downloadmail.



[Viewfullsizeimage]



Inthisfigure,youcanseethatComputerAsendsoutgoing

emailtoitslocalSMTPserveroperatedbytheInternetService

Provider(ISP).ComputerAusesthePOP3protocol(PostOffice

Protocol)tocheckforandretrievemessagesstoredonthe

server.IfComputerAneedstosendanemailtoComputerB,



themessagetravelsfirstthroughSMTPtothelocalSMTP

server.Thisserverlooksupthemailserverforthedomainin

whichtherecipientonComputerBresidesandsendsthe

message,againusingSMTP,toComputerB'sSMTPserver.

WhenComputerBdecidestocheckmessages,itusesPOP3and

getstheemailsentbyComputerA.Notethatifeithercomputer

wantstosendemailtoComputerC,thenstillanotherSMTP

serverbecomesinvolved.

Note,however,thatthereisn'trealcentralization.SMTPservers

communicateamongthemselvesdirectlyanddonotgothrough

anycentralclearinghouse.It'spossiblethatamailmessagewill

takearoutethroughseveralSMTPserverstoreachthe

eventualmailboxthatisthedestinationoftheemail.Whena

clientinitiallystartsasessionwithanSMTPserver,itcangive

theserverasource-route(listofhosts)throughwhichthe

messageshouldtraveltogettoitsdestination.Thisiscalleda

forward-path.Inaddition,theclientcangivetheservera

reverse-path,whichisasource-routetoreturnerrormessages

totheclientifsomethinghappensduringthetransmissionof

theemailmessage.

Becauseitisadecentralizedsystem,theoperationissimplified.

ThefailureofanSMTPserver,hereandthere,doesn'taffectthe

entireInternet.Theonlypeoplewhogettocomplainarethose

whousethedownedSMTPserversfortheiremail.

WhenmailisdownloadedfromanSMTPserverusingPOP3,the

messagesaredeletedfromtheSMTPserver'sdatabaseand

storedlocallyontheuser'scomputer.Ifyoudeletetheemail

messagesstoredlocallyonyourcomputer,theyaregone

forever!



TheSMTPModel

RFC2821recognizesthatanSMTPserverwouldhavetoservice



bothlocalclientsandrelaymailmessagestootherSMTP

serverswhenthedestinationisnotaclientoftheoriginal

server.IntheoriginalRFC,namesweregivenforthedifferent

processesinvolved,dependingonwhoisdoingwhattowhom.

Forexample,SMTPapplicationscanactaseitherofthe

following,dependingonthedirectionoftheflowofinformation:

Sender-SMTPTheclientestablishesatwo-way(fullduplex)sessionwiththelocalSMTPsever.

Receiver-SMTPTheSMTPserverreceivescommandsfrom

theSender-SMTP.TheReceiver-SMTPprocesscanbean

SMTPserverthatcandeliverthemessagetoitsrecipient's

mailboxortoanotherSMTPserver.

Tobringthesedefinitionsup-to-dateusingmoremodern

terminology,theSender-SMTPisnowreferredtointheRFCsas

theSMTPClient(Sender-SMTP)andtheSMTPServer(ReceiverSMTP).

NotethatwhenamessagepassesthroughseveralSMTP

servers,oneserverbecomestheSMTPClientandtheserverto

whichthemessageisbeingsentbecomestheSMTPServer.The

SMTPClientprocessdoesnotalwaysindicatetheoriginalclient

thatcreatedtheemailmessageinthefirstplace.

Infact,therearefourtypesofSMTPserverrolesthatare

dependentontheservicesprovided:

OriginatorAserverthatoriginatesanemailmessageand

sendsitoutontotheInternet(oranintranet).

DeliveryAserverthatreceivesemailmessagesandstores

themfortheclienttoretrieve.



RelayAnSMTPserverthatrelaysanemailmessagefrom

oneSMTPservertoanother,andisnottheoriginatoror

deliverySMTPserver.

GatewayAserverthatactsasago-betweenSMTPand

anothermessagingsystem.Thegatewaymaymodifythe

contentsoftheSMTPmessagetoaccommodatetheother

messagingsystem.

MostoftheoriginaldefinitionofSMTPfromRFC821remains

intact.AfewotherRFCsovertheyearshaveaddedminor

changestotheprotocol,butithasremainedbasicallyasystem

forrequest/replymessages,orinthewordsoftheRFC,alockstepmethod.Arequestismadeandareplyissent.Inthe

originalversion,aclientsendsacommandtotheserverand

theserverrespondswithasinglereply.Theconnectionbetween

theclientandtheSMTPserverisasimpletwo-waychannel

(usingthesingleTCPport25).



SMTPServiceExtensions

SMTPwasdevelopedmorethanadecadeago.Overtimeithas

beennecessarytoprovideadditionalfunctionalitytothe

protocol,calledserviceextensions.Thesewerefirstaddedto

SMTPbyRFC1425,"SMTPServiceExtensions."FurtherRFCs

addedtotheseadditionalservices,whicharenowcoveredby

RFC2821.AnadditionalextensionhasbeenaddedbyRFC

2920,"SMTPServiceExtensionforCommandPipelining."

ServiceextensionsarenegotiatedbetweenSMTPserverstofind

outwhichextensionsaresupportedbyeachserver.Thereare

fourbasiccategoriesofserviceextensions:

Delivery



AuthenticationandSecurity

CommandPipelining

EnhancedStatusCodes

TheInternetAssignedNumbersAuthority(IANA)isresponsible

formaintainingalistofSMTPextensions.Youcanconsultthe

IANAatwww.iana.org.



SMTPCommandsandResponseCodes

ThefirstcommandthattheSender-SMTPclientsendsiseither

theHELOcommandortheEHLOcommand.EHLOisnowthe

preferredcommandandispartofthebasicserviceextensions.

IfanSMTPserverdoesnotsupportadditionalservice

extensions,itwillrespondwithanerrormessageindicatinga

syntaxerror.

ThisisthebasicsyntaxforSMTPcommands:





Inthissyntax,indicatesthatacarriage-returnfollowedby

aline-feedcharacterisusedtosignaltheendofthecommand

line.

Inthefollowingcommands,thetermforward-pathisalistof

hoststhemessagetravelsthroughtoreachitsdestination.The

termreverse-pathisusedtoindicatehowtogetbacktothe

senderoftheemail,whichcanbehelpfulwhenreturningerror

orotherinformationalmessages.



Note

OneimportantthingtonoteaboutSMTPcommands

isthattheyarenotcase-sensitive.Theclientor

servercodemustacceptbothupper-andlowercase

textforcommandsandnotdifferentiatebetweenthe

two.Commandscanevenbeamixtureofupperandlowercaseletters.Thisisnottrue,however,of

usermailboxnames,althoughhostnames(thatis,

theportionoftheemailaddressfollowingthe"@"

sign)alsoarenotcase-sensitive.BecauseSMTP

allowsmailboxnamestobecase-sensitive,the

actualuser'smailboxnamemaybelimitedtoa

particularcaseonsomeserversandshouldbe

preservedbytheserverandtransmittedexactlyas

received.



ThebasicSMTPcommandsincludethefollowing:

HELOThiscommand(orthenextoneinthislist)issentby



theSender-SMTPclienttotheSMTPservertobeginthe

mailtransfersession.Theargumenttothiscommandisthe

hostnameoftheSender-SMTPcomputer.

EHLOThisisnowthepreferredcommandthatreplacesthe

HELOcommandandindicatesthattheSender-SMTPclient



wantstouseSMTPextensions.Thiscommandalsousesthe

DomainnameinsteadoftheIPaddress.IftheSMTPserver

supportsSMTPextensions,itreturnsacodeof250tothe

client.Iftheserverdoesnotsupporttheextensions,it

returnsacodeof500.



AUTHThisstandsforauthenticate.Theuserprovidesa



username/passwordtotheSMTPservertoauthenticatethe

clientbeforemailcanbesent.

ATRNThisstandsforauthenticatedTURN.Afteraclienthas



beenauthenticatedtotheSMTPserver,thiscommand

instructstheReceiver-SMTPtoreturnanOKresponse.In

thatcase,theSMTPservermustassumethefunctionasthe

senderofthemail.Otherwise,theSMTPservercanreturna

BadGatewaymessage(replynumber502)andremainin

theroleasReceiver-SMTP.

DATAThiscommandisfollowedbyactualdatathatmakesup



theemailmessage.Thisincludesboththebodytextand

suchthingsasthesubjectline.

EXPNThisstandsforexpand.Thiscommandrequeststhe



SMTPservertotelltheclientwhethertheargument

includedwiththecommandisamailinglist.Ifso,the

serverreturnsalistofthemembersofthemailinglistto

theclient.

HELPThiscommandinstructstheSMTPservertoreturnhelp



informationtothesender.TheHELPcommandmightor

mightnotcontainarguments.

MAILThiscommandincludesthereversepathasits



argument.Thisisthenameofthesender,butitalsocanbe

alistofhoststhatwereusedtorelaythemailmessage

fromitsoriginalSender-SMTP.Inalistofhosts,thefirst

hostisthecurrentReceiving-SMTPserver.Thelastisthe

destinationoftheemail.

NOOPThisisthe"nooperation"command.Theserver



respondswithOK.



QUITTheSender-SMTPsendsthiscommandwhenitis



finished.TheservershouldreturnanOKmessageandthen

closedownthetransmissionchannel(thatis,TCP

connection).

RCPTThisstandsforrecipient.Theargumentforthis



commandisasinglerecipient,specifiedbyusingaforwardpathlistprecededbythelettersTO:.Ifamailmessageis

beingsenttomorethanonerecipient,aseparateRCPT

commandmustbeissuedforeveryrecipient.

RSETThisabortsthecurrentemailtransaction.TheSMTP



servershouldrespondwithanOKmessage.

SAMLThisstandsforSendandMail.Mailisthetypicaluse



todaywithSMTP.Thesendmethodismeanttobeused

whentheSMTPserverhasbeenimplementedtodeliver

maildirectlytoarecipientthatisactivelyconnected.The

argumentforthiscommand,again,isareverse-path

showingthepathtothedestinationoftheemail.The

reverse-pathtextisprecededbythetextFROM:.

SENDThiscommand,notoftenimplemented,specifiesthat



themailmessagebedelivereddirectlytothedestination,if

it'sactivelyconnected.Ifthiscannotbedone,theserver

returnsamessagecodeof450(themailboxisnot

available).SimilartotheSAMLcommand,theargumentfor

thiscommandisthetextFROM:followedbythereversepathtothedestinationmailbox.

SIZEThiscommandletstheSender-SMTPinformtheserver



ofthesizeofthemailmessageitwantstosend.Thisis

supportedonlybySMTPimplementationsthatusetheSMTP

ServiceExtensions.Theservercanreturnamessage

indicatingthatitcannothandlemailofthesizerequested,

oritcanacceptthemessage.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 26. Internet Mail Protocols: POP3, SMTP, and IMAP

Tải bản đầy đủ ngay(0 tr)

×