POP3 on the command line

1 minute read

You sometimes find the need to run a protocol dialogue on the command line via telnet. I recently had to do this for POP3. In fact it’s quite simple if you follow the example below where lines starting with a plus are responses from the server:

telnet my.pop.server 110
Trying 123.456.789.123...
Connected to my.pop.server.
Escape character is '^]'.
+OK Hello there.
user user@my.pop.server
+OK Password required.
pass secret
+OK logged in.
+OK POP3 clients that break here, they violate STD53.
1 2213
2 2823
retr 1
+OK 2213 octets follow.
[email content]
dele 1
+OK Deleted.
+OK Bye-bye.

The answer of the server could have a slightly different text which differs from server to server. However the dialogue is still the same.

The most common command shows the list below

command explanation
quit terminates the session and deletes messages marked for deletion
stat statistics about total count and size of mails
list list of mail and their size
retr no. retrieve the content of mail with number no.
dele no. mark mail no. for deletion
noop no operation, returns an OK (useful to keep the connection up)
rset resets all changes and marks
top no. lines show the first lines of message number no.
user name authenticate as user name
pass password submit password for current user
uidl show unique ID of each mail (this is used by your POP3 client if you like to keep the mail on the server)