Post Office Porotocl version 3 ( POP3 ) is the protocol used to retrieve emails from a mail server. We generally use email clients like thunderbird, outlook etc to connect to the server and read the emails. But when you want to test your pop3 server it is useful to connect to the server through a direct tcp channel and examine its basic functionalities. The communication with the server is through a series of requests and responses. The requests are also know as pop3 commands and have specified syntaxes.
To start with we have to establish a tcp session with the pop3 server. The is done using the telnet utility to connect to the pop3 server on the pop3 port ( the default is 110, but this can be changed in the pop3 server configuration).
safeer@penguinpower:~$ telnet pop.safeer.in 110
Trying 10.25.0.2...
Connected to pop.safeer.in.
Escape character is '^]'.
+OK Dovecot ready.
The first three lines of the output is common for any telnet session, it just says the connection is successfully established.
The fourth line is the response from the pop3 server. The pop3 server has two standard responses, positive and negative. They start with a positive or negative response code +OK or -ERR respectively followed by a server message. Here the response is positive as you can see, and the message says "Dovecot ready" - dovecot being the pop3 server software running on pop.safeer.in
Once you establish the connection with the server, you have to identify yourself by providing a username and password in the following format.
USER safeer
+OK
PASS fake_Password
+OK Logged in.
This section is self explanatory. Now let us inspect a summary statistics of my mailbox.
STAT
+OK 3 2086
The response code is OK, the second column is the number of messages in the mailbox and the third is the total size of the messages
Let us list all the three messages
LIST
+OK 3 messages:
1 501
2 1035
3 550
.
First line of the response says, the listing is successful ( +OK ) and the mailbox has 3 messages. Subsequent lines list each messages, the first column being the message id and the second being the message size.
Now let us view a mail, to do so issue the command RETR followed by message id.
RETR 1
+OK 501 octets
Return-Path: <info@safeer.in>
X-Original-To: safeer
Delivered-To: safeer@safeer.in
Received: from penguinpower (penguinpower [128.0.0.5])
by smtp.safeer.in (Postfix) with SMTP id C53EFG509TH;
Mon, 24 Jan 2011 10:49:06 +0530 (IST)
subject: POP3 server setup
Message-Id: <20110124051909.C53EFG509TH@smtp.safeer.in>
Date: Mon, 24 Jan 2011 10:49:06 +0530 (IST)
From: info@safeer.in
Mail server setup successfully
.
So the server responded +OK followed by size of the message, and the subsequent lines prints out the email with all the headers included.
Let us delete the message now, issue the command DELE followed by the message id.
DELE 1
+OK Marked to be deleted.
LIST
+OK 2 messages:
1 1035
2 550
Be aware that issuing the DELE command just marks the message for deletion. The actual deletion of message happens when the user disconnects from the current pop3 session. So while you are in the session, it is still possible to recover your message by issuing RSET command.
RSET
+OK
LIST
+OK 3 messages:
1 501
2 1035
3 550
We are done, now exit the session by issuing the QUIT command.
QUIT
+OK Logging out.
If you had messages marked for deletion, the server response would also say "messages deleted"
To learn more about POP3, look at the POP3 RFC at IETF
No comments:
Post a Comment