Testing SMTP Server Using Telnet

SMTP server can be tested simply by using telnet client. On Windows 7 above telnet client has to be installed first via control panel (Windows Add/Remove Features)

Following is a sample SMTP commands to send for a standard mail server listening on IP port 25, without authentication

C:\telnet 25
HELO mycompany.com
MAIL FROM:support@mycompany.com
RCPT TO:gerry@somedomain.com
To: Gerry Tan <gerry@somedomain.com>
From: My Company Support <support@mycompany.com>
Subject: Testing mail server via SMTP
Please ignore this email as this is just testing mail server via SMTP


The two newlines and dot at the end is important.

SMTP Server With Authentication

To use SMTP username / password authentication, you first need to encrypt it to Base64. It can be done with command line perl:

 perl -MMIME::Base64 -e 'print encode_base64("gerrytan");'
 perl -MMIME::Base64 -e 'print encode_base64("Mypass123");'

Becareful if you username / password contains symbols meaningful to perl! An @ character can be interpreted as perl array. You have to escape it using \ (I spent an hour figuring out why authentication failed due to this).

And issue AUTH LOGIN command after HELO / EHLO. The server will prompt for username and password in Base 64

220 mail.tpg.com.au ESMTP (mail16) Sendmail ready.
EHLO mail.tpg.com.au
250-mail16.tpgi.com.au Hello webmail.mxtglobal.com [], pleased to
meet you
250-SIZE 28521268
250 HELP
334 VXNlcm5hbWU6
334 UGFzc3dvcmQ6
235 2.0.0 OK Authenticated
MAIL FROM:gerry@email.com
250 2.1.0 gerry@email.com... Sender ok
RCPT TO:bob@email.com
RC250 2.1.5 bob@email.com... Recipient ok

Thanks to http://exchange.mvps.org/smtp_frames.htm.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s