Testing your SMTP server setup with Telnet

When you set up a new mail server you usually want to run some tests on it to see it delivers the mail like it’s supposed to. There are tools out there to do this for you but the easiest way is to use Telnet. Telnet is found on almost any new operating system, and if it’s not there you can user your package manager to get a client.

Talking to the server

Talking to SMTP servers is really quite easy and they usually reply in a decent matter. The dialog is simple and you need only a few commands to see if everything is alright, let’s get started shall we

[localuser@localhost ~]$ telnet mail.company.com 25

To use telnet just enter the command telnet the server you are connecting to in my test case mail.company.com and the SMTP standard port which is 25.
After that you should see something like this

Trying 192.168.90.25…
Connected to mail.company.com (192.168.90.25).
Escape character is ‘^]’.
220 mail.company.com ESMTP Sendmail 8.13.1/8.13.1; Thu, 31 Jan 2008 21:02:57 +0200

The responding smtp server should say something like the above.

HELO mail.company2.com

As we are a decent mail server we greet our fellow mailserver with HELO and our name.
To which the counterpart should answer

250 mail.company.com Hello mail.company2.com [192.168.81.18] (may be forged), pleased to meet you

As you can see SMTP servers are very civilized in their discussions. Next we need to tell the server who we are delivering mail for. So we say

mail from:postmaster@company2.com

And the answer should be

250 2.1.0 postmaster@company2.com… Sender ok

Now we have to tell the server who we are delivering mail to so we say:

rcpt to:postmaster@company.com

The server checks,or doesn’t check, the recipient depending on your setup and answers

250 2.1.5 postmaster@company.com… Recipient ok

Next we start to send some text. I won’t send any subject and you shouldn’t have to send any data either but it’s good to know how this works so we just type DATA and hit enter.

DATA
354 Enter mail, end with “.” on a line by itself

As the server says we can now input the mail and end the email with a single . on a new line. So just start typing something and when your done hit enter for a new line and the dot . and enter again to end the data send.

This is a test mail.
.
250 2.0.0 m0VJ2vCO016000 Message accepted for delivery

Last but not least end the session in a nice way by typing quit

quit
221 2.0.0 mail.company.com closing connection

That’s it. The mail should now be delivered to you mailbox if everything was configured correctly.

No related posts.