Simple Mail Transport Protocol SMTP

20.1.1 Simple Mail Transport Protocol SMTP

SMTP is the basic e−mail protocol. SMTP stands for simple mail transfer protocol, and it is based on the TCPIP suite. This is the language that sendmail understands well, and peer communication between two involved sendmail programs is actually an exchange of SMTP messages. A simplified presentation of such a communication or rather, a conversation between two arbitrary hosts, identified as ms1.mydomain and ms3.yourdomain, is shown in Figure 20.2. The two hosts communicate directly. The local sendmail is delivering an e−mail from the local user me to the remote user you; it literally talks to the remote hosts sendmail about having an e−mail message from the user me on the local host sent to the user you on the remote host the e−mail address is youms3.yourdomain. The local sendmail conveys the sender and recipient information before it transmits the e−mail message; the address information constitutes the envelope, and it is conveyed separately from the message header. Only one recipient may be listed in the envelope, although the same e−mail could be addressed to more recipients simultaneously. Any division of a multiple−addressed e−mail into multiple single−addressed envelopes must be performed before the address parsing; SMTP assumes a single recipient only. 461 Figure 20.2: A simplified presentation of SMTP. To get a better look at the SMTP protocol, another example using sendmail in verbose mode follows. The verbose mode lists the complete dialogue between the two sendmail programs on the senders and recipients hosts. In this example the e−mail message is sent by the sender bjlpatsy.myschool.scps.edu to the recipient misapollo.ph.myschool.scps.edu; the text for the e−mail is in the file named indata.mail. Again, the two hosts communicate directly there are no relay mailhosts in the e−mail delivery. usrlibsendmail −v misapollo.ph.myschool.scps.edu indata.mail misapollo.ph.myschool.scps.edu… Connecting to apollo.ph.myschool.scps.edu via ether… Trying 146.98.8.31… connected. 220 apollo.ph.myschool.scps.edu HP Sendmail 1.38.193.416.2 ready at Tue, 5 Jul 1998 17:06:13 −0400 HELO patsy.myschool.scps.edu 250 apollo.ph.myschool.scps.edu Hello patsy.myschool.scps.edu, pleased to meet you MAIL From:bjlpatsy 250 bjlpatsy… Sender ok RCPT To:misapollo.ph.myschool.scps.edu 250 misapollo.ph.myschool.scps.edu… Recipient ok DATA 354 Enter mail, end with . on a line by itself . 250 Ok QUIT 221 apollo.ph.myschool.scps.edu closing connection misapollo.ph.myschool.scps.edu… Sent 462 The first two lines are messages at the senders host, describing what sendmail is doing: m i s a p o l l o . p h . m y s c h o o l . s c p s . e d u … C o n n e c t i n g t o apollo.ph.myschool.scps.edu via ether… Trying 146.98.8.31… connected. ♦ T h e f i r s t l i n e s h o w s t o w h o m t h e e − m a i l i s a d d r e s s e d a n d t h a t t h e h o s t apollo.ph.myschool.scps.edu is on the network. The second line shows the IP address of the recipients host in this case the IP address was obtained by DNS. • Once the senders sendmail has connected to the recipients host, it waits for the other side to initiate further conversation. The recipient says it is ready by sending the number 220 followed by its domain name this is the only required information; the program name usually, but not always, sendmail; and the version of that program. It also states that it is ready and gives its local date and time. 220 apollo.ph.myschool.scps.edu HP Sendmail 1.38.193.416.2 ready at Tue, 5 Jul 1998 17:06:13 −0400 ♦ • Next, the senders sendmail sends the hello message HELO this is not a typo; the recipient replies with 250 and the acknowledgment that the senders hostname is acceptable: HELO patsy.myschool.scps.edu ♦ 250 apollo.ph.myschool.scps.edu Hello patsy.myschool.scps.edu, pleased to meet you ♦ • If all has gone well so far, the senders sendmail sends the name of the e−mail sender the user on that host from the envelope of the e−mail message; the recipients sendmail accepts the senders name and replies with the message starting with the number 250: MAIL From:bjlpatsy ♦ 250 bjlpatsy… Sender ok ♦ • Next, the senders sendmail sends the name of the e−mail recipient the user on the remote host from the envelope of the e−mail message; the recipients send−mail accepts in this case or rejects this name then it would reply with an error User unknown. The reply starts with the number 250: RCPT To:misapollo.ph.myschool.scps.edu ♦ 250 misapollo.ph.myschool.scps.edu… Recipient ok ♦ • After the envelope information has been sent, the senders sendmail attempts to send the e−mail data header and body combined: DATA ♦ 354 Enter mail, end with . on a line by itself ♦ . ♦ The DATA message essentially tells the recipient to get ready for a data receipt; the sent data is not displayed, and only a single dot on a line by itself is used to mark the end of a mail message — this is a convention of the SMTP protocol. To prevent misinterpretation of any lines in the e−mail body that could contain a single dot, the senders sendmail inserts an extra dot at the beginning of any line that begins with a dot; the recipients sendmail removes those extra dots. • After the e−mail message has been successfully sent, it is confirmed by the recipients • 463 250 Ok ♦ QUIT ♦ 221 apollo.ph.myschool.scps.edu closing connection ♦ The last line simply confirms that the e−mail message was successfully delivered: misapollo.ph.myschool.scps.edu… Sent ♦ •

20.1.2 The MTA Program sendmail