POP3 is becoming an antiquated protocol to connect to a mail server, it is quite useful to test if a mail account is set up properly.
Normally I just try to login and stop there, but there are some more commands in your POP3-toolbox.
||Login to the account
||Login with the password
||Close the connection.|
||Shows the number of messages and the total size of the mailbox.|
||Displays a list of messages with their numbers and respective sizes, or a single message number with its size.|
||Displays a list of messages with unique identifiers for each message.|
||Display the header and body content of the specified message.|
||Display the header of the specified message. If
||Mark the specified message for deletion.|
||Clears any delete flags set by the
||Does nothing, simply used to avoid server timeouts.|
There are just 2 replies possible with POP3:
-ERR, meaning, you guessed it, that your command was successful or that it failed.
It is possible that these replies are followed by some more information to show the result of a command or the reason of the error.
Connect to the server
We’re going to use
telnet to connect to the mail server.
$ telnet example.com 110
And we’re greeted by a welcome message:
Connected to example.com. Escape character is '^]'. +OK POP3 server ready.
The server is waiting for our first command. So let’s try to login. First we need to provider our username:
USER <username> +OK
Followed by our password (Note: it will be shown as plaintext!):
PASS <password> +OK Logged in.
Success, we’re in!
Working with messages
To display a list of the messages in our mailbox:
LIST +OK 5 messages: 1 3375 2 3622 3 3606 4 3630 5 3834
This will tell you how many messages there are and will also give a list with on each line a message number and the message size in bytes (you gotta love those old’n days where people were concerned about disk space).
STAT command will also tell you the number of messages, plus the total size of the mailbox:
STAT +OK 5 18067
You have 2 similar commands to your disposal for reading messages:
RETR. Both commands will show you the content of a message and therefore need a message number. But
TOP also accepts a second parameter so you can specify the number of lines of body content to show (it will always show the headers). When no lines are specified it is assumed to be 0.
TOP 1 +OK Return-Path: <email@example.com> Delivered-To: firstname.lastname@example.org Received: from localhost (localhost [127.0.0.1]) by example.com (Postfix) with ESMTP id 10315142CF8 for <email@example.com>; Mon, 23 Feb 2015 13:19:37 +0100 (CET) Date: Mon, 23 Feb 2015 04:19:35 -0700 From: <firstname.lastname@example.org> To: email@example.com Message-ID: <78AF5C73C263AF24BA943DEEBB142316@example.com> Subject: Just a test message
To delete a message we can use the
DELE 1 +OK Marked to be deleted.
If the message does not exist or has been deleted, you will see the following error messages:
DELE 1 -ERR Message is deleted. DELE 9999 -ERR There's no message 9999.
The message is not deleted instantly, this will only happen when you close the connection. To recover the deleted message before you log out, you can use
This will clear any delete flags that have been set.
To close the connection and actually delete any messages marked for deletion:
QUIT +OK Logging out.