Saturday, June 9, 2007

Using Telnet to simulate server communication

The best place to run Telnet is on the server which sends out your SMTP traffic. This will show you the same information that your SMTP engine receives when communicating with an outside system. Telnet allows you to specify the port through which to communicate. SMTP is defined as TCP port 25.

Open a command prompt window. Determine the FQDN or the IP address. If you need to determine this information, you can use NSLookup if you know the SMTP domain name you are attempting to connect to. For more information about this, read this article.

At the prompt, type telnet fqdn 25

If the receiving server is accepting SMTP communications, it will respond with an acknowledgement message indicating it is ready to receive your transmission. The acknowledgement should also indicate if it understands SMTP or ESMTP.

Type ehlo testdomain.com

There are two established protocols, SMTP and ESMTP (Enhanced SMTP). If the receiving system only understands SMTP, you must begin with helo. If the receiving system understands ESMTP, you may begin with either helo or ehlo.

If you receive an OK message from the receiving mail system, proceed. If not, double check the protocol named in the response to the telnet command.

Type
mail from:exchange.admin@testdomain.com

This indicates the reply address. Some receiving systems will compare the parameter from the ehlo command, and the domain listed in the address on the mail from: command to the domain name returned when performing a reverse DNS (RDNS) lookup on the IP address from which the message is coming. It is a method to combat address spoofing and more reliably identify undesirable senders.

If you are testing communications to an outside messaging system, you may need to use your actual domain name to be allowed to continue.

Type
rcpt to:valid.user@receivingdomain.com

This indicates the recipient address. If receivingdomain.com is not a domain being fielded by the receiving system, and the system does not allow relaying to receivingdomain.com, an error code will be returned.

Type data

This begins the actual message. Optionally, From:, To:, and BCC: can be entered at this time (to be covered in a future article).

Type subject: Test message via Telnet

Type a blank line - this denotes the end of the subject and the beginning of the message body.

Type This is a test
Type Please reply if received
Type a blank line
Type a period (".") and press Enter - this marks the end of the message body. The receiving system will understand and return a prompt.
Type quit

This ends the Telnet session and you will be returned to the OS prompt.

If everything has gone well, the message will be on its way to the recipient address. Give it a minute and check. You now know how to manually create and send an SMTP message! This can be a great troubleshooting tool, as you will receive reponses and acknowledgements from the receiving system that can aid in diagnosing a communication problem.

8 comments:

Anonymous said...

hi
i've a problem with our Smtp server which i hope that you can help.

hello Mr.Akhlaghi
we still have the same problem on our Mail Server:
*******************************************************
Event Type: Warning
Event Source: smtpsvc
Event Category: None
Event ID: 4006
Date: 1/1/2008
Time: 7:08:55 AM
User: N/A
Computer: GW
Description:
Message delivery to the host '209.191.88.247' failed while delivering to the remote domain 'yahoo.com' for the following reason: The connection was dropped by the remote host.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:

Words 0000: c00402d3
Bytes 0000: d3 02 04 c0 Ó..À
*******************************************************
i telnetted to yahoo.com domain on port 25 & was able to send email with no problem .
i will define my network topology below.
+ a windows 2000 domain exist which consist of 3 Exchange servers ( 2 of the exchange 2000 & 3rd is exchange 2003 ) all of them are in one routing group send emails to the Local Bridgehead (Exchange 2000 server) & this server sends email to our Mail Relay Server (SMTP Server ,Windows 2003,also GFI Mailessential & Security exist on the server ) which resides in DMZ & finally this server sends emails to other SMTP servers Worldwide via ISA 2000 server which allows access to Mail Relay Server & all IP protocols are open for it.

Any suggestion that may lead to solving our problem is appreciated.
------------------------------
akhoshbin1975@yahoo.com
ali_khoshbin@hotmail.com

Anonymous said...

Thanks for this easy to follow tutorial. Question: I'm not sure what the mail server is doing with domain name after "ehlo" since it seems I can put anything here, but a blank is not accepted.

DVP Rao said...

Hi:
Thanks for this tutorial.
I am seeing the follwoing :can you please help in deciphering the error message ?
thanks - DVP
===================================
220 mail39.megamailservers.com ESMTP Sendmail 8.13.6.20060614/8.13.1; Fri, 14 Ma
r 2008 13:38:48 -0400
ehlo chalmersgroup.com
250-mail39.megamailservers.com Hello exchange.chalmersgroup.com [209.250.132.2],
pleased to meet you
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-SIZE 52428800
250-DSN
250-AUTH PLAIN LOGIN
250-STARTTLS
250-DELIVERBY
250 HELP
mail from:dvpr@chalmersgroup.com
250 2.1.0 dvpr@chalmersgroup.com... Sender ok
rcpt to:sales@jvcelectric.com
551 5.1.8 Relaying denied: From address can not be a remote host, please enable
SMTP authentication.

500 5.5.1 Command unrecognized: ""
==================

mboed[No]tabi said...

when i'm sending email i don't have problem but when i can receive email always error 554 recipient address rejected

Moe the Great said...

And what would/could you do if some Mailhost accept your telnet and others don't?

Anonymous said...

Hi!!! exchangeguy.blogspot.com is one of the most excellent innovative websites of its kind. I take advantage of reading it every day. Keep it that way.

Unknown said...

I really appreciate your work.
it saved my time.

Anonymous said...

This is helpful, thanks, though it would also be great to know how to authenticate to the server.