Unix Network Admin   «Prev  Next»
Lesson 5SMTP and sendmail
ObjectiveDescribe how sendmail uses the SMTP protocol to forward email across the Internet.

How Sendmail uses the SMTP protocol to forward email

The sendmail agent uses the Simple Mail Transport Protocol (SMTP) to forward email across the Internet. SMTP is an application-layer Internet protocol. It, and other aspects of the Internet email system, is described in a series of Request for Comments documents (RFCs). You can obtain RFCs free of charge from many locations, including the RFC Editor Homepage.

Email RFCs

Some of the more important RFC documents pertaining to email are RFC 821, 822, and 1123. RFC 821 specifies that the Simple Mail Transfer Protocol (SMTP) uses port 25, that its primary transport protocol is TCP, and several other requirements. RFC 822 determines how MUAs, MDAs and MTAs format and send email. Among other things, RFC 1123 contains a helpful discussion of the requirements for Internet-enabled email hosts. Even if you use a completely different MTA than sendmail, you are implementing the principles set out in these three documents.

An SMTP session using sendmail

220 mail.corporation.com ESMTP sendmail 8.9.3; Tue, 13 Jul 1999
14:04:19 -
Helo linuxhost.corporation.com
250 linuxhost.corporation.com Hello [], pleased to meet you
Mail From: james@linuxhost.corporation.com
250 james@linuxhost.corporation.com... Sender ok
RCPT To: sandi@corporation2.com
250 sandi@corporation2.com... Recipient ok
354 Enter mail, end with "." on a line by itself
From: james@linuxhost.corporation.com
To: sandi@corporation2.com
Message ...
250 OAA00328 Message accepted for delivery

Click the View Example button to examine an example of a simple SMTP session. The linuxhost box is sending an SMTP mail message via mail.corporation.com to a remote host (sandi@corporation2.com). The message is from user james on linuxhost.corporation.com (james@linuxhost.corporation.com), but
will write the headers so that the message appears to come from james@corporation.com. his is an example of masquerading. Note also that ESMTP stands for “Extended” SMTP; this is a fancier version of the SMTP protocol in common use.
Received: from mail.corporation.com 
( []) by
mail.corporation2.com with SMTP (sendmail 8.8.9)
id NMCCV3MT; Tue, 13 Jul 1999 14:14:25 -0700
Received: from mail.corporation.com ([])
by mail.corporation2.com (8.9.3) with SMTP 
id OAA00333
for sandi.corporation2.com; Tue, 13 Jul 1999 
14:14:27 -0700
Date: Tue, 13 Jul 1999 14:14:27 -0700
From: james@corporation.com
Message-Id: <199907132114.OAA00333@mail.
Message ...

Once this session is completed, mail.corporation will forward the message to sandi@corporation2.com. Numbers such as 220 and 250 indicate RFC 821 success messages. Click the View Example button to examine the RFC 822 header information contained in the email message received by sandi@corporation2.com. This session shown in the example was successful because mail.corporation.com relays messages from linuxhost.corporation.com, then routes it to mail.corporation2.com. Notice that the headers have changed. This is because the linuxhost sendmail daemon used masquerading. This enabled sendmail to rewrite the headers during transmission to make the james@linuxhost.corporation.com address appear as james@corporation.com.
You will learn more about how to configure your sendmail daemon in upcoming lessons.