Since I have some POP3 mailbox, I have seen the POP3 protocol, translating the core part of it.
Commands in the POP3 protocol contain keywords that are not case sensitive and may follow 1 or more parameters. All commands end in CRLF. Keywords and parameters contain printable ASCII characters. Each keyword and parameter are separated by a single Space character. The keyword length is 3 or 4 characters. Each parameter is up to 40 characters.
The response in the POP3 protocol contains a status indicator and a keyword that may follow additional information. All responds end with CRLF. Contains the ended CRLF, the length of the response is up to 512 characters. There are currently 2 status indicators: correct (" OK") and errors ("-err"). The server must send " ok" and "-err" in a capital form.
The response of some commands is multi-line. In this case, after transmitting the response and CRLF of the first row, the additional line ending at the end of the CRLF is transmitted. When the response is sent, the last row contains an end byte (046, ".") And CRLF. So a multi-line response end tag is five bytes ("crlf.crlf"). When a multi-line response is checked, if the line starts with an end byte, and the next byte is not CRLF, the first byte (end byte) is removed.
Authorization Status Once the client's TCP connection is opened, the POP3 server sends a line of welcome information, which may be any correct response. Such as: OK POP3 Server Ready. The session of the POP3 is in the Authorization state.
Transaction Status This state is: Stat: The server responds to information about the mailbox. The response form is as follows: OK, space, the number of letters, space, email size (in bytes), additional information (optional), CRLF. List [MSG]: Parameter MSG: Letter Number, cannot reference letters marked as deletion. If you do not have a parameter, the information of the letter is included in the response. The response form is as follows: Letter number, space, and the exact size of the letter (in bytes), additional information (optional), CRLF. Example: C: Lists: OK 2 Messages S: 1 120S: 2 200
RETR MSG: Parameter MSG: Letter Number, cannot reference letters marked as deleted. The content of the server responds to the contents of the letter (multi-line).
Dele Msg: Parameter MSG: Letter Number, cannot reference letters marked as deleted. Mark the number of the number MSG as delete, and any command to reference the letter number will be wrong. The server performs actual deletion in the UPDATE state.
NOOP: The server does not do anything, just returning to OK.
RSET: Unpacking any letters marked as delete.
UPDATE Status: The client sends a quit command, the server enters the UPDATE state. Quit: The server deletes all the letters marked as deleted and responds to the status of this operation.
Optional POP3 command: Top MSG N: Parameter MSG: Letter number; N: Number of lines. If the server gives the correct response, the format of the response is as follows: OK, letters, blank, N rows of letters.
UIDL [MSG]: Parameter MSG: Letter Number. Response form: Letter number, space, unique number of letters. User name: Parameter Name: Logo the string of the mailbox. Even if there is no mailbox exists, the server may also return the correct response. If the mailbox exists but does not support the password authentication of ordinary text, the server may also return an error response.
Pass string: Parameters String: Password. Spaces are identified as part of the password.
APOP NAME Digest: Parameter Name: Label the string of the mailbox; Digest: MD5 string. The server that supports the APOP command will contain timestamps in the welcome information. The syntax of the timestamp corresponds to "MSG-ID" in RFC822. The client notes the timestamp and sends an APOP command. The name parameter is the same as the USER command, the Digest parameter is calculated on the timestamp plus shared key application MD5 algorithm [RFC1321].