Troubleshooting Email, The Telnet Way
Scott Forsyth
July 11, 2005
Email is used daily by everyone from the top executives to the 5 year olds sending
messages to their friends. But are there any good tools available to test and resolve
issues? Email tends to be weaker when it comes to troubleshooting tools.
One tool I'll briefly plug is SMTPDiag from Microsoft.
Released in the fall of 2004 it's a great tool for any email troubleshooting.
Today I want to cover a more basic, yet in some ways, more powerful email troubleshooting
tool. Many people do not realize that you can easily and quickly send a test message
using Telnet, a tool available with most operating systems.
Using Telnet, you can connect to your mail server directly as if you were an email
program. Don't stop reading yet because it sounds difficult, it isn't, and it can
benefit you more than you realize! Whether you're an administrator that manages
mail servers, a technical person that likes to keep up on cool things, or you're
a home user wanting to find out why your email message weren't sent , this simple
walk-through is for you.
Now, why would you want to connect directly to the mail server? There are several
reasons but let's give an example. Let's say that all of a sudden you can no longer
send email and you're not sure why. Is it your mail server, your email program,
your firewall, your ISP or what? This test will give you some solid clues to help
isolate the issue.
There is one thing to keep in mind when using Telnet. A backspace might appear to
work in your Telnet session but the mail server won't accept it as a backspace.
So, if you type the email address or a command wrong, don't use the backspace to
correct it. You should press enter and try again. You may need to quit and start
again. You can see the affect of a backspace by using the backspace key in the body
of the email and seeing what it looks like when you receive the email.
Let's dive in: Note, if you want to skim and just use the actual commands, just
type in the words in red.
Open a command prompt on your computer and connect to the mail server over port
25. Let's say your mail server is called smtp.example.com, then in Windows, you
can do this from the command prompt by typing
"telnet smtp.example.com 25" without the quotes.
At this point you should see a small bit of information at the top of the telnet
screen. Something similar to "220 smtp.example.com". This is the mail server's initial
welcome. If you received a similar response, you have successfully connected. But
if you get a timeout and you are not trying to use your ISP's mail server, there
is a chance that your ISP has blocked port 25. Some mail servers also listen on
alternate ports, for example 587, so you can try connecting using 587 instead of
25. If neither work and you are sure your internet connection is working, you should
contact your ISP to try to get the block removed. Alternately you may be forced
to use your ISP for all outgoing email.
Now, let's start talking to the server. Type
"helo me"
and enter.
Then set the From and To addresses, type the following lines and enter separately:
Mail from: myaddress@orcsweb.com
Rcpt to: youraddress@orcsweb.com
At this point, the mail server should say if the recipient was approved or not.
Some mail servers know at this point if it will allow it, some will accept the message
and reject it later if it is invalid. For the most part you can tell already if
there is an issue with the sending or receiving email address.
Now we are ready to start into the Data part. Here we can keep it plain and simple
and start typing the body, or we can add some friendly headers to make the email
look better. I will include the friendly part at the top, but during testing it
is not required.
First type:
"Data" and press enter
Next add the headers and body:
From: "Scott Forsyth" <myaddress@orcsweb.com>
To: "Your name" <youraddress@orcsweb.com>
Subject: This is a test message sent from telnet
Here is where the body goes. Notice that one blank line is required between the
headers and the body of the email. Again, the three headers aren't required. They
can be in any order and they aren't case sensitive either. You can also get away
with just the email address there like so:
To end the Data / body, there needs to be a line with only a "." (period) on it,
and then press enter. Like so:
.
That's it. You should receive a brief status about the message and then you can
exit by typing "Quit" and enter.
Your message should be sent.
This is surprisingly easy. Just remember the key details. Some mail servers don't
require the helo me but it is a good habit to always enter it (
"ehlo
me" will also work with most mail servers).
For a quick test for troubleshooting, here is a bare bones example:
===========
telnet smtp.example.com 25
helo me
mail from:myaddress@orcsweb.com
rcpt to:youraddress@orcsweb.com
data
This is a test
.
===========
Here is yet another example with an image to show the whole process.
That is sufficient to send a test message on most mail servers.
Telnet is a powerful tool for testing email and really comes in handy for isolating
mail related issues.
Scott Forsyth is the Director of IT
with ORCS Web, Inc.
- a company that provides managed hosting solutions for clients who develop and deploy their applications on Microsoft Windows platforms. Services include shared hosting, dedicated hosting, and webfarm hosting, with specialty in .Net, SQL Server, and architecting highly scalable solutions.