13.07.2015 Views

Mail Transfer SMTP Specification SMTP basics

Mail Transfer SMTP Specification SMTP basics

Mail Transfer SMTP Specification SMTP basics

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Mail</strong> <strong>Transfer</strong><strong>SMTP</strong> (RFC2821) (was RFC821)Simple Command/Response ProtocolClient sends a commandServer respondsSpecified in partial (kind of) ABNFThe first step in the procedure is the MAIL command.MAIL FROM: [SP ] The second step in the procedure is the RCPT command.RCPT TO: [ SP ] <strong>SMTP</strong> <strong>Specification</strong>ehlo = "EHLO" SP Domain CRLFhelo = "HELO" SP Domain CRLFehlo-ok-rsp = ( "250" domain [ SP ehlo-greet ] CRLF )/ "250-" domain [ SP ehlo-greet ] CRLF*( "250-" ehlo-line CRLF )"250" SP ehlo-line CRLF )ehlo-greet = 1*(%d0-9 / %d11-12 / %d14-127); string of any characters other than CR or LFehlo-line = ehlo-keyword *( SP ehlo-param )ehlo-keyword = (ALPHA / DIGIT) *(ALPHA / DIGIT / "-"); additional syntax of ehlo-params depends on; ehlo-keywordehlo-param = 1*(%d33-127); any CHAR excluding and all; control characters (US-ASCII 0-31 inclusive)Allows client to identify itselfAnd allow server to state its capabilities<strong>SMTP</strong> <strong>basics</strong>ClientHELO client-domain-nameMAIL FROM:RCPT TO:DATAE-mail messagetakes multiple linesso ends with a linethat is just a dot.QUITServerWelcomeOKOKOKSendOKOKBannerit


Commands and ResponsesCommands4 letters (by convention)spaceparametersResponsesSingle Line3 digit codespacehuman messageMultiple Lines3 digit codehyphen "-"human messagesame 3 digit codehyphen (if more lines to follow) space otherwisehuman messageResponse CodesFirst Digit gives response type1Information2All OK3More input required4Temporary Error5Permanent ErrorSecond digit gives specific response typeThird digit gives extra informationAllows error codes to be distinguishedFile <strong>Transfer</strong> Protocol (FTP)FTP uses an unusual communication modelTraditional Client/Server (<strong>SMTP</strong>/DNS/...) :CSClient and serverClient opens TCP connection to serverClient sends commands over connectionServer sends responses back over same connection


FTP ModelClient and two ServersS1S2RFC959CClient opens TCP control connectionto first serverAnd another TCP control connectionto second serverClient sends commands to both serversGets responses from serversFTP model (2)Command to one servercauses it to open TCP data connectionto other serverS1S2RFC959CCommand to server causes it to transfer data over data connectionData transfer can be in either directionCommon FTP UsageClient and one server in same systemCSClient opens TCP control connectionClient sends commands, gets responsesCommand causes server to open data connection to other server (ie: client)Data Connection opened by either endDepends upon which server client sharesData transfer occurs over data connectionData transfer can be in either direction


FTP Control ConnectionVery similar to <strong>SMTP</strong><strong>SMTP</strong> was once part of FTP4 letter commands, plus parameters3 digit (+ message) responseMulti-line responses possibleSome responses contain information for softwareAuthentication commandsCommands to set optionsCommands to cause data connection setupCommands to cause data transfer to occurFTP Data ConnectionUsed for "File Data" OnlyFile Data includes process outputdirectory listingsHas MODE and TYPEMODE - format of data transferSTREAMPAGEBLOCKTYPE - interpretation of data transferredASCIIIMAGELogical Bytes (with byte size)Designed to allow like systems to be ableto transfer fileswithout reformatting at either endBut to also allow dissimilar systemsto exchange meaningful informationCreating Data ConnectionsClient must tell server location of other serverEven if other server is the clientAnd/or must tell other server to expect incoming connectionEasy if other server is clientDoneBy requesting address & port numberat server to be target of connectionBy sending address & port numberto create a connection


Data connection methodS1S2CClient command connections to 2 serversClient to server: prepare to receive dataServer replies with its address and portClient to other server: use this addressThat server remembers value, says OKPASVPORTData connection method (2)S1S2CClient tells one server to store a fileServer says OK, and expects incoming dataClient tells other server to send a fileServer opens data connection as requestedsends filetells client transaction in progressWhen complete, server tells client all doneActive vs PassiveFor 2 party FTPClient is one of the serversData transfer to or from clientThe normal caseClient chooses to send PASVThen open data connection to serverAt address+port server specifiesClient chooses to send PORTServer opens data connectionTo client at address+port specifiedAlways from PORT 20Active FTP used to be almost universalProblems caused by firewallsNow Passive FTP used almost everywhereHard to classify FTP data transfer connectionsPASSIVEACTIVEFTPFTP


Problem for IPv6Address is an IPv4 addressProtocol specifies 6 numbers each 0-2554 give IP address2 give port numberHow to extend to IPv6?FOOBARFTP Operation Over Big Address RecordsNew command LPRT (Long PoRT)replaces PORTgive length of address & portany number of bytesAnd LPSVreplaces PASVreturns same infoProblem with NATNAT translates addresses in headersBody of message might be encryptedFTP has an encryption extensionHow to handle addresses in data?No way in simple NATRequires Application Level GatewayFTP client to ALG in NAT boxALG client of FTP serverAll hidden from FTP client/serverCannot do authentication/encryptionHidden ALG could not remain hiddenProblems caused by addressesPORT commandPASV responseFOOBAR did not fix thisAlternative solutionNote that most connectionshave only client & serverClient already knows server IP addressv4 or v6It connected to serverServer already knows client IP addresssees where connection came fromNo need to transmit IP addressesin most casesMake them optional


EPRT & EPSVNew command EPRT (Extended PoRT)Address typeAddressPortseparated by delimitersNo fixed lengthsNo need to specify lengthCompatibility ?If unknown at servererror code - client uses PORTIf address type unknownserver indicates which types it knowsAlso EPSVOnly returns portNo addressesRequire EPSV in 2 party FTPAlways use passive mode

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!