MS Exchange, SMTP, POP3 and Telnet

by Lee Derbyshire [Published on 11 Aug. 2002 / Last Updated on 11 Aug. 2002]

The visual complexity of modern email clients such as Outlook Express hides the simplicity of the underlying protocols that they use. If you know a few simple protocol commands it’s possible to send and receive emails via an Exchange Server with no GUI client whatsoever, if you have access to a telnet client.

Introduction

The visual complexity of modern email clients such as Outlook Express hides the simplicity of the underlying protocols that they use. Such clients communicate with compatible servers (which include MS Exchange) using the SMTP and POP3 protocols. These protocols have been around for several decades and if you know a few simple protocol commands it’s possible to send and receive emails via an Exchange Server with no GUI client whatsoever, if you have access to a telnet client.
 

Telnet 

Telnet forms part of the basic TCP/IP protocol suite and is therefore to be found on most machines that have TCP/IP installed. It is a very useful diagnostic tool that we can use to establish a connection to a remote computer (via a particular ‘port’) issue commands to the remote computer, and see the responses it produces. The syntax used to run the telnet program is; telnet , where computer is the hostname, or IP address of the remote computer, and port is the TCP/IP port number that the service we are using runs on. We’ll see how we can use telnet to send and receive emails.
 

SMTP

SMTP is the TCP/IP protocol used to send emails via the Internet. It uses port number 25, so in order to use telnet to open an SMTP session with an Exchange server we use the command telnet 25 . In the example in figure 1, we are using the Windows 98 Run command to open a session with the computer at IP address 192.168.1.2.

 


Fig. 1 – Running telnet on Windows 98.

If the connection is successful, we should see a banner and a CLI interface such as that shown in figure 2. The SMTP service has a help command that we can use to show the list of commands available.
 


Fig. 2 – The SMTP HELP command.

The commands used to send a message using SMTP are; mail from: , which is used to identify the sender; rcpt to: , which identifies the destination address; and data , which is where we can type in the message body. If we type in ‘subject:’ followed by a blank line in the data part, we can supply a subject line for the message. The data part is terminated by a CRLF.CRLF sequence, in other words; we type in a carriage return, a full stop and another carriage return. The quit command is used to close the session. A typical SMTP dialogue is shown in figure 3:
 


Fig 3 . – A typical SMTP dialogue.
 

POP3

POP3 is the TCP/IP protocol that is used to retrieve Internet mail from a server. It uses port number 110, so to open a POP session with our Exchange server we use the command telnet 110 as shown in figure 4:
 


Fig. 4 – Opening a POP3 telnet session.

The commands used to retrieve email using POP3 are; user , which identifies the mailbox we want to open; pass , which we use to supply the password for the mailbox; list, which shows us a list of available messages and their size; and retr , which displays the numbered message on the telnet console. Other useful commands are; dele , which deletes a numbered message from the server, and top , which will display the first n lines of the numbered message. We close the session with quit as before. A typical POP3 dialogue is shown in figure 5. Note that MS Exchange expects the user name to be supplied in a particular, non-standard format; // .
 


Fig. 5 – A typical POP3 dialogue.

Here we can see the message we submitted earlier using SMTP. Figure 6 shows the same message opened in MS Outlook. Note the presence of the subject line and the absence of a date/time-sent field. This can be specified in a similar way to the subject: field by using ‘date:’ within the data part of a message.
 


Fig. 6 – The SMTP message in MS Outlook.
 

Notes 

If you want to learn more about the SMTP and POP3 protocols, search for RFC 821 , and RFC 1939 . These are the documents that describe the official specifications of these protocols.
 

About The Author

Lee Derbyshire BSc (Hons), MCSE is a full-time IT Professional living in the UK. You can visit his Web page at www.leederbyshire.com

 

Advertisement

Featured Links