Test SMTP Connection using TELNET

Test SMTP Connection using TELNET

This short article covers how to test SMTP Connection to Mail Server using TELNET

Prerequisite:

  • TELNET Installed on client
  • Network flow from the client server and Mail Server should be Open

First we will launch telnet on the port listening for mail application on the SMTP Server. It can be port 25,465 or 587. We will be using port 25.

telnet <mail server DNS/IP> <port>

The next command we will execute is EHLO or HELO. This is a greeting message that will start the communication between TELNET Client and Mail Server. We should also specify the domain we will be sending the mail from.

EHLO <Domain>

You should obtain something similar to the following output:

250-<mail server DNS> says hello
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250-8BITMIME
250-XACK
250-XMRG
250-SIZE 54525952
250-VERP
250 DSN

Or something like this depending of the SMTP commands the server accepts:

250-STARTTLS
250-8BITMIME
250 SIZE 53477376

Then we use the Mail FROM command which will determines the address to which bounces are sent.

MAIL FROM: <[email protected]>

Check if you have inserted the angle brackets if you encouter Syntax Error in Mail Command.

Ensure that the domain you are using is registered on your mail server as variations can cause errors to appear.

Now that the MAIL FROM command has been sent, we will issue RCPT TO command which will indicates the server what will be the recipient's address (always cross-check the destination mail address).

RCPT TO <[email protected]>

Before starting the body of the mail, we will send the DATA command. It will let the SMTP Server know that everything else will be the Body of the message. This is where we will also specify the headers to be sent.

We will leave a blank line between the Headers and the Actual body.

To tell the Server the message is completed we will leave a blank line and insert "." on a blank line. If you need a "." on a line by itself, you should use ".."

DATA
From: "Test" <[email protected]>
To: "Test2" <[email protected]>
Subject: Test MAIL

Hello, 
Here a test mail
regards 

.

A code 250 should be obtained.

Now that the mail has been queued, it will go through the SMTP Server and will be in your inbox if is it successful.