SMTP, an application layer protocol

The simple mail transport protocol (SMTP) is used to send e-mail, and the post office protocol (POP) is used to read e-mail.

Windows comes with an e-mail client called Outlook Express which combines both SMTP and POP programs. Letís use SMTP for an application layer illustration. We will not use an e-mail client program, but will manually type the SMTP commands as if Outlook Express or some other e-mail client were issuing them.

The first step is to establish a TCP session between our client machine and a host running an SMTP server using telnet. We must specify the host to connect to and which of the server we wish to communicate with. I know there is an SMTP server running on smtp.csudh.edu (155.135.20.14) and that it is listening on port 25, so I opened up a DOS window and gave the telnet command:

Note that the port number is included at the end of the command line.

When I typed the above command, the server responded with a ready message:

S: 220 dhims01.campus.csudh.edu ESMTP Server (Microsoft Exchange Internet Mail Service 5.5.2653.13) ready

I was now in communication with the SMTP server running on smtp.csudh.edu. As far as it was concerned, I was an email client program. SMTP protocol messages consist of a command followed by parameters. Some of the commands are:

helo: identify the client domain (domain name)
mail: identify the sender (email address)
rcpt: identify the recipient (email address)
data: the body of the message
quit: end the session

The following is a transcript of my first SMTP session. C denotes commands I typed, and S shows the server response:

C: helo csudh.edu
S: 250 OK
C: mail from:<lpress@csudh.edu>
S: 250 OK - mail from <lpress@csudh.edu>
C: rcpt to:<lpress@csudh.edu>
S: 250 OK - Recipient <lpress@csudh.edu>
C: data
S: 354 Send data.  End with CRLF.CRLF
C: from: lpress@csudh.edu
C: to: lpress@csudh.edu
C: subject: Message to myself

C: This is from me to me.
C: .
S: 250 OK

A second later, lpress@csudh.edu received the following email:

Here is another SMTP session. Note that I overwrote the from address, making it look like President Bush invited me for lunch, and that he cannot spell very well:

C: mail from:<lpress@csudh.edu>
S: 250 OK - mail from <lpress@csudh.edu>
C: rcpt to:<lpress@csudh.edu>
S: 250 OK - Recipient <lpress@csudh.edu>
C: data
S: 354 Send data.  End with CRLF.CRLF
C: from: gwb@wh.gov
C: to: lpress@csudh.edu
C: subject: Lunch

C: Lar,

C: Let's have lunche tommorroww.

C: GWB
C: .
S: 250 OK

A second later, lpress@csudh.edu received the following email:

I then typed a quit command, and the session was terminated:

C: quit
Connection to host lost.

C:>
Note that the client and server programs were "conversing" with no awareness of the nature of the links between them -- the complexity of the communication network was hidden.

Finally, note that the client does not display everything that is received. The full message appears below, and it reveals the identity of the machine that sent the message:

Received: from LPNewPortable.dyn.csudh.edu ([10.13.0.153]) by dhims01.campus.csudh.edu
with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13)
id SVP0282P; Mon, 22 Sep 2003 20:53:30 -0700
from: gwb@wh.gov
to: lpress@csudh.edu
subject: Lunch

Lar,

Let's have lunche tommorroww.

GWB

For more on information on SMTP check out the RFC Sourcebook.