Manual test for the POP3 connection

This post will explain the procedure for manual testing of the e-mail receiving process. This procedure is useful for system administrators or programmers to narrow down problems in an operation of their e-mail server.

We can reproduce entire POP3 e-mail exchange process with manual typing of all commands. We can use this procedure when we need to test proper work between an e-mail server and an e-mail client.

We will use any telnet client. That can be Windows telnet client (you can install it as a feature in Windows 7 and later), putty or any other telnet capable program.

In our exam we will be user01@company.com. We will working on workstation WS01.COMPANY.COM. Our e-mail server is MAIL.COMPANY.COM. For this demonstration I used the telnet client in the Windows 8 and the hMail e-mail server.

Our commands are written in CAPS LOCK. We don’t need to do that when we testing system. I used CAPS LOCK just for visibility. Server response begins with +OK and some text message. Alternatively, server can respond with –ERR, when some error occur.

 

Accessing the mailbox

The session begins by opening the telnet connection:

C:\>telnet mail.company.com 110

The terminal window will open and from now on we are in the telnet session. We will simulate interactive session on same way as our e-mail client doing.

The e-mail server will respond with:

+OK POP3

We must enter our username and the password. That’s the difference with the SMTP test, where we didn’t authenticate ourselves. Be aware that password will be visible.

USER user01
+OK Send your password
PASS password01
+OK Mailbox locked and ready

 

Checking the mailbox content

First command which we should type is a command LIST. The e-mail server will return a list of all e-mails in our inbox and their size in bytes. Please, pay attention on the output. All commands that returns more than one line will print the character dot (.) as the last line

LIST
+OK 4 messages (1061 octets)
1 245
2 245
3 272
4 299
.

The command LIST can be used with optional argument X, where X is an ordinal number of the message that we want to check.

LIST 3
+OK 3 272

We can alternatively use a command STAT. That command returns the statistics of mailbox. We can see total number of the messages (e-mails) and their size in the bytes (or an octets). We don’t need to use it in our tests.

STAT
+OK 4 1061

 

Working with the messages

We are ready to access to the messages in our mailbox. We can use any of following commands to access a message content.

For reading of the whole message we will utilize a command RETR X, where X is ordinal number of message in the list. This parameter is mandatory.

RETR 3
+OK 272 octets
Return-Path: user01@company.com
Delivered-To: user01@company.com
Received: from ws01.company.com (ws01.company.com [192.168.2.14])
by mail.company.com
; Tue, 18 Mar 2014 16:14:31 +0100
Message-ID: <89C7E05A-26DD-4CD0-9227-B63FF0D963D3@mail.company.com>
From: <user01@company.com>
Subject: Test
aaa
.
RETR 4
+OK 299 octets
Return-Path: user01@company.com
Delivered-To: user01@company.com
Received: from ws01.company.com (ws01.company.com [192.168.2.14])
by mail.company.com
; Tue, 18 Mar 2014 16:15:57 +0100
Message-ID: <3CE49252-F470-4920-8B3D-D6898C20B544@mail.company.com>
From: user01@company.com
CC: user02@company.com
Subject: Test 2
aaa
.

If we want to check just part of the message, like the header lines, we will use command TOP X Y, where X is ordinal number of message in the list and Y is the number of the lines we want to see on screen. First Y lines, including the header lines, will be displayed.

TOP 2 5
+OK 245 octets
Return-Path: user01@company.com
Delivered-To: user01@company.com
Received: from ws01.company.com (ws01.company.com [192.168.2.14])
by mail.company.com
; Tue, 18 Mar 2014 16:07:10 +0100
Message-ID: <C0CC2802-3566-4A5F-AD88-1B1DADBEB1E7@mail.company.com>
Subject: Test
aaa
.

 

Deleting the messages

We will demonstrate how to delete any message. Please, pay attention that this part is often root of the problem in some applications. Developers read messages, but often forget to delete them.

First step is to make a list of all messages. We will use the command LIST.

LIST
+OK 4 messages (1061 octets)
1 245
2 245
3 272
4 299
.

We want to delete second message.

Command for deletion is DELE X, where X is a ordinal number of the message in the list. We can delete only single message in any moment. No batch deletion, sorry.

DELE 2
+OK msg deleted

Last step is to check results. We will again list all messages and there is no message number 2:

LIST
+OK 3 messages (816 octets)
1 245
3 272
4 299
.

 

Closing the session

When we want to finish session, we must issue command QUIT. This is the proper way.

QUIT
+OK POP3 server saying goodbye...

Connection to host lost.

Press any key to continue...

It’s often happens that poorly written application just dropping a connection without the QUIT command. That can lead to the command DELE is not being executed. If you want to delete files and you just drop a connection, the server will always play safe and will keep messages in inbox.

Therefore, if you see that your messages are still in the inbox, check the order of the commands that your application exchanging with the server.

Advertisements

One thought on “Manual test for the POP3 connection

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