Protocol Conventions
Post Office Protocol, version 3
POP3 RFC 1939, J. Myers & M. Rose
POP3 uses TCP port 110.

Command Responses
All command responses begin with a status line. The status line consists of a status indicator and a keyword possibly followed by additional information. There are currently two status indicators: positive ("+OK") and negative ("-ERR"). Single line command results are generally provided as additional information which follows the status indicator.

Some commands provide a multi-line response which follows a positive status line. After the status line, the server sends additional lines, each terminated by a CRLF pair. When all lines of the response have been sent, a final line is sent, consisting of a termination octet (decimal code 046, ".") and a CRLF pair. If any line of the multi-line response begins with the termination octet, the line is "byte-stuffed" by pre-pending the termination octet to that line of the response. Hence a multi-line response is terminated with the five octets "CRLF.CRLF".

Command Summary
USER name
Defines the user name for access to a maildrop.
  The user name and password string provide authentication and access to a maildrop.

The server may return a positive response even though no such mailbox exists. The server may return a negative response if mailbox exists, but it does not permit plaintext password authentication.
PASS string
Defines the password string for access to a maildrop.
The user name and password string provide authentication and access to a maildrop.

If a positive response is received, the maildrop is locked and is ready to receive transaction commands.

Since the PASS command has exactly one argument, a POP3 server may treat spaces in the argument as part of the password, instead of as argument separators.
APOP name digest
Provides maildrop access with an encrypted password
  Allows maildrop authentication without sending a password in the clear over the network.

Servers that implement APOP authentication include an RFC822 ‘msg-id’ timestamp in their banner greeting. The `digest' parameter is calculated by applying the MD5 algorithm [RFC1321] to a string consisting of the timestamp (including angle-brackets) followed by a shared secret (e.g. the password). The `digest' parameter itself is a 16-octet value which is sent in hexadecimal format, using lower-case ASCII characters.
QUIT Terminates the session.
  If messages were marked as deleted, the server attempts to remove them from the maildrop. If an error is encountered while removing messages, some or none of the messages marked as deleted will be removed.

Whether the removal was successful or not, the server then releases any exclusive-access lock on the maildrop and closes the TCP connection.
STAT
Provides ‘drop-listing’ status of the maildrop.
  The minimal drop listing response is an "+OK" followed by a single space, the number of messages in the maildrop, a single space, and the size of the maildrop in octets. More advanced implementations may include other information.
LIST [msg]
Provides ‘scan-listing’ summary of messages in the maildrop.
  If an argument is given, the scan listing for the message follows the positive response header. With no argument, a multi-line response follows with a scan listing for each message in the maildrop.

A scan listing consists of the message-number of the message, followed by a single space and the exact size of the message in octets. More advanced implementations may include other information, as parsed from the message.
RETR msg
Retrieves a message from the maildrop.
  The message is sent as a multi-line response, being careful to byte-stuff the termination character.
DELE msg
Mark the msg as deleted from the maildrop.
  Any future reference to the message-number associated with the message in a command generates an error. The server does not actually delete the message until the session enters the UPDATE state via the QUIT command.
NOOP
No operation.
  The server replies with a positive response.
RSET
Reset all messages that are marked as deleted to unmarked.
  The server replies with a positive response.
TOP msg lines
Sends the headers and the requested lines from the indicated msg.
  The headers and lines are sent as a multi-line response. Note that if the number of lines requested is greater than the number of lines in the body, the entire message is sent.
UIDL [msg]
Provides ‘unique id listing’ of messages in the maildrop.
  If an argument is given, the unique-id-listing for the message follows the positive response header. With no argument, a multi-line response follows with a unique-id-listing for each message in the maildrop.

A unique-id-listing consists of the message-number of the message, followed by a single space and the unique-id of the message. No information follows the unique-id.

The unique-id of a message is an arbitrary server-determined string, consisting of one to 70 characters in the range 0x21 to 0x7E, which uniquely identifies a message within a maildrop and which persists across sessions.

Note that messages marked as deleted are not listed.