热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

POP3协议详解

POP3协议详解文章目录POP3协议详解authorizationtransactiondownload-and-deletedownload-and-keepupdatePOP3

POP3协议详解


文章目录

  • POP3协议详解
    • authorization
    • transaction
      • download-and-delete
      • download-and-keep
    • update



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
  • pass

为了搞清楚这两个命令,我们建议你最好使用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协议提供的一些常用服务。有疑问欢迎留言呀!



推荐阅读
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 本文介绍了如何使用Express App提供静态文件,同时提到了一些不需要使用的文件,如package.json和/.ssh/known_hosts,并解释了为什么app.get('*')无法捕获所有请求以及为什么app.use(express.static(__dirname))可能会提供不需要的文件。 ... [详细]
  • IjustinheritedsomewebpageswhichusesMooTools.IneverusedMooTools.NowIneedtoaddsomef ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 本文介绍了为什么要使用多进程处理TCP服务端,多进程的好处包括可靠性高和处理大量数据时速度快。然而,多进程不能共享进程空间,因此有一些变量不能共享。文章还提供了使用多进程实现TCP服务端的代码,并对代码进行了详细注释。 ... [详细]
  • 本文介绍了计算机网络的定义和通信流程,包括客户端编译文件、二进制转换、三层路由设备等。同时,还介绍了计算机网络中常用的关键词,如MAC地址和IP地址。 ... [详细]
  • 利用Visual Basic开发SAP接口程序初探的方法与原理
    本文介绍了利用Visual Basic开发SAP接口程序的方法与原理,以及SAP R/3系统的特点和二次开发平台ABAP的使用。通过程序接口自动读取SAP R/3的数据表或视图,在外部进行处理和利用水晶报表等工具生成符合中国人习惯的报表样式。具体介绍了RFC调用的原理和模型,并强调本文主要不讨论SAP R/3函数的开发,而是针对使用SAP的公司的非ABAP开发人员提供了初步的接口程序开发指导。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • 预备知识可参考我整理的博客Windows编程之线程:https:www.cnblogs.comZhuSenlinp16662075.htmlWindows编程之线程同步:https ... [详细]
  • 本文介绍了Shell中for命令的基本格式和用法,通过提供一个值列表来迭代执行一系列命令。同时还介绍了如何读取列表中的值,并给出了for命令与其他命令的结合使用示例。 ... [详细]
  • 移动端常用单位——rem的使用方法和注意事项
    本文介绍了移动端常用的单位rem的使用方法和注意事项,包括px、%、em、vw、vh等其他常用单位的比较。同时还介绍了如何通过JS获取视口宽度并动态调整rem的值,以适应不同设备的屏幕大小。此外,还提到了rem目前在移动端的主流地位。 ... [详细]
  • iOS超签签名服务器搭建及其优劣势
    本文介绍了搭建iOS超签签名服务器的原因和优势,包括不掉签、用户可以直接安装不需要信任、体验好等。同时也提到了超签的劣势,即一个证书只能安装100个,成本较高。文章还详细介绍了超签的实现原理,包括用户请求服务器安装mobileconfig文件、服务器调用苹果接口添加udid等步骤。最后,还提到了生成mobileconfig文件和导出AppleWorldwideDeveloperRelationsCertificationAuthority证书的方法。 ... [详细]
author-avatar
夕祈文_279
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有