Home » Linux, Macintosh, Windows

Send a Test Mail Using Telnet

10 July 2011 No Comment

Send a Test Mail Using TelnetWhen you are having a problem sending a mail message, the first thing you want to do is test the SMTP (Simple Mail Transfer Protocol) connectivity. By default, SMTP listens on port 25. By using telnet, you can connect to port 25 on the mail server and test whether or not you can send a message. This step is done on your own workstation. If you are having a problem sending mail from a web form, run this step from the server that is storing the web form.

Whether you are on Windows, Mac or Linux, you can open a command line interface and run telnet. Telnet should already be installed by default. The steps outlined below will work on Windows, Mac or Linux. The output of the message received from the mail server may be different though.

An adaptation of these steps can be used in Linux if you want to send a message from a cron job.

To start a telnet session, open the command line application in Windows or terminal session in Mac or Linux. Type the following command:

telnet mail_server_name port_number

where mail_server_name is the name of the mail server such as mail.myserver.com and port_number is 25 in this case.

For example,

telnet mail.myserver.com 25

If you are able to connect to the mail server, you should see something like the following:

220 mail.myserver.com ESMTP Postfix

If you get a 220 response, it means you can connect with the SMTP server. Before starting the conversation with the mail server, it is polite to acknowledge your presence. You would do so with the ehlo command.

To get a response back from the mail server, type:

ehlo test.com

If successful, you should get a response such as the following:

250-SIZE 10240000
250 DSN

When connecting to a Windows mail server, you might just get one 250 response. As long as you get a 250 response, it means the communication is working.

250 OK

The next step is to specify where this message is coming from.

mail from:henry@test.com

If successful, you should get a 250 response back such as:

250 2.1.0 Ok

To specify the recipient of the message, type

rcpt to:jane@myserver.com

You should get another 250 response:

250 2.1.5 Ok

The next step is to tell the mail server that you are ready to send some data.


It will respond back with the message that you can end the data with a dot on an empty line.

354 End data with <CR><LF>.<CR><LF>

You can specify the subject line by typing:

subject:Hello Jane

Press ENTER two times. You will not get any message back. It is now time to write the body of the message.

This is a test message.


Note the lone period at the end of the line. It designates the end of the message. Without it, the message has not ended yet.

After you type the period at the end of the line, you will get this response:

250 2.0.0 Ok: queued as 4186E786435

At this point, the message has been sent and you can end the session by typing:


Verify that you have received the message that you just sent.

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.