POP3协议详解

POP3协议详解


POP3是一个非常简单的 邮件访问协议。

Post Office Protocol version 3 (POP3) is a standard mail protocol used to receive emails from a remote server to a local email client.

因为这个协议非常简单,所以这个协议的功能很少。

什么时候会用到这个协议呢?
POP3 begins when the user agent (the client) opens a TCP connection to the mail server (the server) on port 110.

当TCP连接建立好之后,POP3 progresses through 3 phases:

  • authorization
  • transaction
  • update

一脸懵逼

authorization

the user agent sends a username and a password (in the clear,明文)to authenticate the server.

在这个阶段有两个主要的命令:

  • user <username>
  • pass <password>

为了搞清楚这两个命令,我们建议你最好使用Telnet直接登录到a POP3 server, using port 110, and issue these commands.

说实话,我对telnet不太了解,我只知道可以使用命令敲击。然而我的电脑是mac的,telnet不知道什么时候已经装好了。先不研究telnet吧。

假定 mailServer 是你的邮件服务器的名称,You will see something like:

telnet mailServer 110
+OK POP3 server ready
user bob
+OK
pass hungry
+OK user successfully logged on

If you misspell a command, the POP3 server will reply will an -ERR message.

所以mailServer必须要是一个POP3 server吗?

下面举个实在点的例子吧。武大人都有武大邮箱,我们就拿武大邮箱来举个例子吧。
命令不多,我就直接截图了。
在这里插入图片描述
可以看到在+OKd的后面写了个397 messages,
这说明了在我的服务器的收件箱中一共有397条消息。
真的吗,呵呵
在这里插入图片描述
确实,分毫不差

transaction

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.

也就是说只要在最后执行quit命令之后,才会真正的删除,并不是我一旦执行dele命令,就会进行更新的。

使用list命令查看每一条消息的大小
在这里插入图片描述
在这里插入图片描述
当list不加任何参数的时候,就是默认列出所有邮件的大小。
当我们指定邮件的编号时,就可以列出指定邮件的大小:
在这里插入图片描述
使用retr命令获取第1条消息
在这里插入图片描述
通过武大邮箱看一看第一条消息是什么样的呢?
在这里插入图片描述
大体可以看出,获取的是一样的消息。

我突然想起来,当年屈道涵学长是不是就是这样把我们的作业邮件搞下来的。

download-and-delete

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.

至此,我已经讲解完毕了POP3协议提供的一些常用服务。有疑问欢迎留言呀!

  • 3
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
POP3(Post Office Protocol Version 3)协议是一种用于接收邮件的应用层协议。其工作过程如下: 1. 客户端发送连接请求:客户端向POP3服务器发送连接请求,建立TCP连接。 2. 客户端发送身份验证信息:客户端发送用户名和密码进行身份验证。 3. 服务器验证用户身份:POP3服务器验证客户端发送的用户名和密码是否正确,如果验证通过,服务器会返回一个欢迎消息。 4. 客户端请求邮件列表:客户端发送LIST命令获取服务器上所有邮件的编号和大小。 5. 服务器返回邮件列表:POP3服务器返回邮件列表,客户端可以根据邮件的编号和大小决定是否下载该邮件。 6. 客户端请求下载邮件:客户端发送RETR命令请求下载某封邮件,服务器返回该邮件的内容。 7. 服务器删除邮件:如果客户端想要删除某封邮件,可以发送DELE命令进行标记删除。当客户端退出连接时,服务器会删除所有标记为已删除的邮件。 8. 客户端退出连接:客户端发送QUIT命令退出连接,服务器关闭TCP连接。 总之,POP3协议的工作流程是非常简单的,客户端通过发送命令可以实现下载、删除等操作,但是需要注意的是,POP3协议不支持向服务器发送邮件。同时,因为POP3协议使用明文传输用户名和密码,所以存在安全风险。建议在使用POP3协议时,使用SSL或TLS协议加密连接,提高安全性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值