Troubleshoot SMTP Connection with Telnet


SMTP can be defined as a process which is used to pass mail from one destination to another.  SMTP is defaulted to port 25 and this port is used for external sending and routing of email.  However, in an internal network, this can be set to pretty much any port for Transmission of SMTP traffic, as long as the receiving servers are also configured the correct way.
If you are running into issues and need to verify connectivity with SMTP you can use the following steps.
 Telnet IllustrationTelnet:  Telnet is a terminal application available in most OS platform by default. (In Windows 7 and Server 2008 you will need to enable telnet via Add/Remove Features)

To use telnet you an open a command line and type the following command:
Telnet the.destination.IP 25
The destination IP can be DNS based Name or just the IP if you know the IP.

If you are unable to connect here, many common issues for this is a firewall or the telnet services on the box are off.
Sometimes, you may notice that it connects then disconnects suddenly.   This may be an issue with the MTA to verify, edit the path for inbound and place it in proxy mode temporarily to see if it reacts the same.
If the box has multiple IP's, be sure to check if it has a virtual IP, if it does, there are issues with the inbound path being bound to a virtual IP.   This IP should be the real IP.
Upon connect with the telnet session you should get a response stating that you are connected, the escape character, and a number that is 220 followed by the mail servers host name (assuming it isn't spoofing).

From here you can verify delivery from the command line
The first response that a mail server is looking for is a HELO or and EHLO, this needs to be followed by something, it doesn't matter what, i.e.,
                             HELO nemesis.local
                             EHLO hiall.nemesis.local

Most Modern Servers use EHLO to send.
EHLO is the extended SMTP rules that give more options when sending mail, whereas HELO is the original command sets.   In most machines EHLO is tried first and if there is no response then HELO is used.  However, in cases that I have looked at with several different people, this is not the case with mail server, if EHLO fails to connect it will not send HELO communication and then terminate the session.
Occasionally, there are receiving servers out there that only receive HELO requests, thus mail server will not be able to send to these people and you will need to place the software in the debug mode and send the message to the server in question that is refusing delivery again, then go look at the SMTP Logs for the transaction.

You will see that it is sending a EHLO to the server and it is not excepting the EHLO. If this is the cause, the user will have to contact the sender’s side and request that
EHLO be activated.
In the case that when you connect it spews the following type of line,
220 ************8***********80*************
Or the like, it is usually because they have a firewall, usually a Cisco Pix that is in “fixup” mode.   This is a mode on the router that is used to encode some information that comes through it.   It is used when someone is making changed to the firewall and often times it is forgotten about.   This will cause some issues.

Now once connected to port 25 you will need to send a mail.
The following steps should be in order.  Comments will be in ()

EHLO Nemesis.local
  mail from:<> (This is the from envelope, system messages and NDR is sent with <>)
  rcpt to:<>

 data   (place subject, to and from headers here.)

  Subject: Squirrels, when is enough, enough?
  To: Recipient Joe
  From: Squirrel Mackey
  This is a message to place body inside of the message that will be sent.
   (A Solitary period will mark the completion of the message and connection termination.)
You are done with the message and you can type quit to get out of the SMTP interface. Once you have verified that this is sent or not sent, you can take the applicable steps in regard to the issue at hand.


Comments (1)

rcpt to: command return failed with "550 unable to relay for".  is this because we use an email filtering service (smart host) as a relay?

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.