How to manually send the e-mail

This post will explain procedure for manual testing of the e-mail sending process. When you’re in doubt does your e-mail server works correctly, you can follow this procedure and check functionality.

We can manually simulate the client-server connection with the e-mail server whenever we need to test a connection or troubleshoot an errors in the communication.

We don’t need any special program. Only one tool that we need is a telnet client. That can be the Windows Telnet client (we can install it as a feature on Windows 7 and later versions), putty or any other utility.

 

Our demo environment

In our examples, we will be an user user01@company.com, working on the workstation WS01.COMPANY.COM, and we should communicate with the e-mail server MAIL.COMPANY.COM.

All commands that we should type begin with capital letters (like HELO, MAIL FROM, etc.). You don’t need to type them in using all caps.  We used them in caps here to highlight SMTP commands and to separate them from additional information specific for every server.

The server response are lines that begin with number and the message behind it, like 220 mail.company.com ready. Those codes and most of the responses are predefined and well known. We can find a whole list of the SMTP codes in the separate post.

The client workstation were a computer with Windows 8.1 operating system. We will use standard Windows Telnet client. The e-mail server used in this demonstration was a hMail server.

 

The first test example

In the first case, we will show to you how to do the simplest test.

The session begins by opening the telnet connection:

C:\> telnet mail.company.com 25

 

The terminal window will open and from now on we are in the telnet session.

The e-mail server will respond with its full Internet name and, optionally, software version:

220 mail.company.com ready

 

We should send command HELO and our full DNS (FQDN) name. If you don’t send HELO on the beginning of communication, there is a huge chance that the server can reject further communication, treating you as a spammer. The server will respond with a greeting message:

HELO ws01.company.com

250 Welcome mail.company.com

 

We want to send the e-mail and we will said that to the server with command MAIL FROM:, followed with our e-mail address:

MAIL FROM:user01@company.com

 

The server will respond with following line, when an address is recognized as correct:

250 user01@company.com Sender Ok

 

Next step is to enter recipient with the command RCPT TO:e-mail_address. This command should be entered for every recipient separately.

RCPT TO:user01@company.com

 

If our server will accept that recipient, we will type the command DATA and we will start to fill the message body. We will finish our message with sequence [ ENTER ][ . ][ ENTER ] (press the keys Enter, dot, Enter)

250 user01@company.com Recipient Ok

DATA

354 Enter mail, terminate with “.” alone on a line

Subject: Test

Test

[ ENTER ]

.[ ENTER ] <—– this is [ ENTER ][ . ][ ENTER ] sequence

 

The server will respond with

250 Message accepted for delivery

 

We can now finish our session with command QUIT and we will be again in the command prompt window.

QUIT

221 mail.company.com closing connection.

Connection to host lost.

C:\>

 

The e-mail message body is everything typed between command DATA and sequence [ ENTER ].[ ENTER ]. In our example this is:

Subject: Test

Test

 

The recipient of this message will see this e-mail like message with the subject Test and only Test inside message. We will not see dot we typed on the end.

However, this e-mail will not have From field. Although we used command Mail From, that is just e-mail address of the sender. That field is not a name of the sender. We will see later how to add From field.

 

Checking extended capabilities

In our second case, we will show to you few more commands. We will explain just those new commands. Rest of the process is same as in the first case.

The session will begins again with the telnet session.

C:\> telnet mail.company.com 25

 

The terminal windows opens and from now on we are in the telnet session.

220 mail.company.com ESMTP

HELO ws01.company.com

250 Hello.

 

Now we will ask the server for advanced capabilities. The list of an advanced capabilities can be longer on feature rich server, like Microsoft Exchange:

EHLO ws01.company.com

250-mail.company.com

250-SIZE 2048000

250 AUTH LOGIN PLAIN

 

Now we are going to type in and send our test e-mail:

MAIL FROM:user01@company.com

250 OK

RCPT TO:user01@company.com

250 OK

DATA

354 OK, send.

Subject: Test

aaa

.

250 Queued (9.672 seconds)

 

This case shows us that we can find maximal message size and some other capabilities, like the login methods. We will not analyze those methods here, but just to mention that they allow us to use encrypted username and password in communication with the e-mail server. A standard communication method uses open text exchange mechanism. Our username and a password are sent in clear, human readable, text.

 

Resetting a connection

Our third case assume that we made some mistake in communication and we want to restart session. We will use command RSET and we can begin new session. We should follow same steps as in our previous cases:

RSET

250 OK

HELO ws01.company.com

250 Hello.

EHLO ws01.company.com

250-mail.company.com

250-SIZE 2048000

250 AUTH LOGIN PLAIN

MAIL FROM: user01@company.com

250 OK

RCPT TO: user01@company.com

250 OK

 

This e-mail will have even the From: field, that will appear in our e-mail client. Therefore, our message will looks like this:

DATA

354 OK, send.

From: <user01@company.com>

Subject: Test

aaa

.

250 Queued (21.704 seconds)

 

As you can see, additional headers like From or Subject can be wrote in message body.

 

Refreshing session and keeping connection alive

In our last case, we will demonstrate how we can keeping connection alive, even if we’re not sending e-mail messages. We can archive that with the command NOOP.

We are still in open session. Let we assume that we’re just continuing previous case. Therefore, our next command will be:

NOOP

250 OK

 

We can repeat this command as many times as we need.

In meantime, we checked our e-mail client and we saw that our test message is in the Inbox. We can finishing the  session with the command QUIT.

QUIT

221 goodbye

Connection to host lost.

Press any key to continue…

 

The server’s angle of view

Best way to troubleshoot a problem in the communication is to observe the e-mail server in same time. We should check the e-mail server log. It should report same commands and sequences, as we typed in a telnet client..

Here is an example of one session containing our last three cases:

service session id date&time client IP message
DEBUG 18.03.2014. 15:59:50 Creating session 3843
SMTPD 3843 18.03.2014. 15:59:50 192.168.2.14 SENT: 220 mail.company.com ESMTP
SMTPD 3843 18.03.2014. 16:02:02 192.168.2.14 RECEIVED: HELO ws01.company.com
SMTPD 3843 18.03.2014. 16:02:02 192.168.2.14 SENT: 250 Hello.
SMTPD 3843 18.03.2014. 16:02:13 192.168.2.14 RECEIVED: EHLO ws01.company.com
SMTPD 3843 18.03.2014. 16:02:13 192.168.2.14 SENT: 250-mail.company.com[nl]250-SIZE 2048000[nl]250 AUTH LOGIN PLAIN
SMTPD 3843 18.03.2014. 16:02:36 192.168.2.14 RECEIVED: MAIL FROM:user01@company.com
SMTPD 3843 18.03.2014. 16:02:36 192.168.2.14 SENT: 250 OK
SMTPD 3843 18.03.2014. 16:02:46 192.168.2.14 RECEIVED: RCPT TO:user01@company.com
SMTPD 3843 18.03.2014. 16:02:46 192.168.2.14 SENT: 250 OK
SMTPD 3843 18.03.2014. 16:02:48 192.168.2.14 RECEIVED: DATA
SMTPD 3843 18.03.2014. 16:02:48 192.168.2.14 SENT: 354 OK, send.
SMTPD 3843 18.03.2014. 16:02:57 192.168.2.14 SENT: 250 Queued (9.235 seconds)
SMTPD 3843 18.03.2014. 16:02:57 192.168.2.14 RECEIVED:
SMTPD 3843 18.03.2014. 16:12:54 192.168.2.14 RECEIVED: RSET
SMTPD 3843 18.03.2014. 16:12:54 192.168.2.14 SENT: 250 OK
SMTPD 3843 18.03.2014. 16:13:04 192.168.2.14 RECEIVED: HELO ws01.company.com
SMTPD 3843 18.03.2014. 16:13:04 192.168.2.14 SENT: 250 Hello.
SMTPD 3843 18.03.2014. 16:13:13 192.168.2.14 RECEIVED: EHLO ws01.company.com
SMTPD 3843 18.03.2014. 16:13:13 192.168.2.14 SENT: 250-mail.company.com[nl]250-SIZE 2048000[nl]250 AUTH LOGIN PLAIN
SMTPD 3843 18.03.2014. 16:13:25 192.168.2.14 RECEIVED: MAIL FROM: user01@company.com
SMTPD 3843 18.03.2014. 16:13:26 192.168.2.14 SENT: 250 OK
SMTPD 3843 18.03.2014. 16:14:07 192.168.2.14 RECEIVED: RCPT TO: user01@company.com
SMTPD 3843 18.03.2014. 16:14:07 192.168.2.14 SENT: 250 OK
SMTPD 3843 18.03.2014. 16:14:10 192.168.2.14 RECEIVED: DATA
SMTPD 3843 18.03.2014. 16:14:10 192.168.2.14 SENT: 354 OK, send.
SMTPD 3843 18.03.2014. 16:14:32 192.168.2.14 SENT: 250 Queued (21.704 seconds)
SMTPD 3843 18.03.2014. 16:17:58 192.168.2.14 RECEIVED: NOOP
SMTPD 3843 18.03.2014. 16:17:58 192.168.2.14 SENT: 250 OK
SMTPD 3843 18.03.2014. 16:21:15 192.168.2.14 RECEIVED: QUIT
SMTPD 3843 18.03.2014. 16:21:15 192.168.2.14 SENT: 221 goodbye
DEBUG 18.03.2014. 16:21:15 Ending session 3843

 

Comparing our typed commands and the server logs, we can narrow down the problem.

On the end, just to mention that we can checking an e-mails from the telnet session, but that’s another story.

Advertisements

One thought on “How to manually send the e-mail

Leave a Reply

Fill in your details below or click an icon to log in:

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