the user agent retrieves messages; also during the phase, the user agent can mark messages for deletion, remove deletion marks and obtain mail statistics.
In a POP3 transaction, the user agent issues commands, and the server responds to each command with a reply. 有两种可能的回复:
+OK (sometimes followed by server-to-client data),used by the server to indicate that the previous command was fine.
-ERR, used by the server to indicate that something was wrong with the previous command.
A user agent using POP3 can often be configured (by the user) to “download and delete” or “download and keep”. The sequence of commands issued by a POP3 user agent depends on which of these two modes the user agent is operating in.
In the download-and-delete mode, the user agent will issue the
list
retr
dele commands.
As an example, suppose the user has 2 messages in his or her mailbox.
In the dialogue below, C: (standing for client) is the user agent and S: (standing for server) is the mail server. The transaction will look something like:
C: list S: 1 498 S: 2 912 S: . C: retr 1 S: (blah blah ...) S: ....................... S: .............blah) S: . C: dele 1 C: retr 2 S: (blah blah ...) S: ................... S: ...........blah) S: . C: dele 2 C: quit S: +OK POP3 server signing off
上面这一连串命令都是在你本地电脑的命令行中敲的。 这一连串命令是什么意思呢? The user agent first asks the mail server to list the size of each of the stored messages. The user agent then retrieves and deletes each message from the server. 注意,这个user agent仅使用了4个命令。
list
retr
dele
quit
这些命令的语法is defined in RFC 1939. After processing the quit command, the POP3 server enters the update phase and removes messages 1 and 2 from the mailbox.
A problem with this download-and-delete mode is that the recipient, Bob可能是一个到处跑的产品经理, may want to access his mail messages from multiple machines. 举个例子, his office PC, his home PC, and his portable computer.
The download-and-delete mode partitions Bob’s mail messages over these 3 machines: In particular, If Bob first reads a message on his office PC, he will not be able to reread the message from his portable PC at home later in the evening.
download-and-keep
In the download and keep mode, the user agent leaves the messages on the mail server after downloading them. In this case, Bob can reread messages from different machines; he can access a message from work and access it again later in the week from home.
update
the update phase occurs after the client has issued the quit command, ending the POP3 session; at this time, the mail server deletes the messages that were marked for deletion.
During a POP3 session between a user agent and the mail server, the POP3 server maintains some state information; In particular, it keeps track of which user messages have been marked deleted.
However, the POP3 server does not carry state information across POP3 sessions. The lack of state information across sessions greatly simplifies the implementation of a POP3 server.