简体   繁体   English

GMail 和 POP3 RETR 问题 - 切换到 IMAP?

[英]GMail and POP3 RETR problem - switch to IMAP?

When I'm accessing GMail inbox using POP3 protocol, it seems that after fetching given email using RETR command, after QUIT-ting and reconnecting, previously RETR-ieved email is not listed anymore when calling LIST.当我使用 POP3 协议访问 GMail 收件箱时,似乎在使用 RETR 命令获取给定电子邮件后,在退出并重新连接后,在调用 LIST 时不再列出以前使用 RETR 发送的电子邮件。

Then, after going to: GMail settings//Forwarding and POP/IMAP and setting "Enable POP for all mail (even mail that's already been downloaded)", on next login all emails are being LIST-ed again, but if I RETR any of them, it again disappears from LIST after re-logging..然后,在转到:GMail 设置//转发和 POP/IMAP 并设置“为所有邮件(甚至已经下载的邮件)启用 POP”后,下次登录时,所有电子邮件都会再次被列出,但如果我退回任何邮件其中,重新登录后它再次从 LIST 中消失..

I can then go to GMail settings again and repeat the whole process, but it's a show-stopper for me as I'm writing a script that should work without any manual actions.然后我可以再次转到 GMail 设置并重复整个过程,但这对我来说是一个阻碍,因为我正在编写一个无需任何手动操作即可工作的脚本。

Am I missing something, or only IMAP can help here?我是否遗漏了什么,或者只有 IMAP 可以在这里提供帮助?

(EDIT: RFC http://www.ietf.org/rfc/rfc1939.txt doesn't say a word about RETR command deleting messages) (编辑:RFC http://www.ietf.org/rfc/rfc1939.txt没有提及 RETR 命令删除消息)

This is intended behaviour of Gmail.这是 Gmail 的预期行为。 According to this question , "[a]ll messages may be downloaded to another computer once; after downloading mail, it will not download again."根据这个问题,“[a]ll 邮件可能会下载到另一台计算机一次;下载邮件后,它不会再次下载。”

There's also a 'recent mode' , in which the last 30 days of mail are fetched, regardless of whether it's been sent to another POP client already.还有一种“最近模式” ,即获取过去 30 天的邮件,无论它是否已经发送到另一个 POP 客户端。

That said, don't try to fetch all your mail by different computer in a short period of time, as Gmail may block your account for 24 hours .也就是说,不要尝试在短时间内通过不同的计算机获取所有邮件,因为Gmail 可能会阻止您的帐户 24 小时

I strongly suggest using IMAP.我强烈建议使用 IMAP。

Gmail's POP3 configuration maybe sometimes confusing. Gmail 的 POP3 配置有时可能令人困惑。 You can find Gmail POP3 behavior here .您可以 在此处找到Gmail POP3 行为

Switching to IMAP is very good solution.切换到 IMAP 是非常好的解决方案。

This is a common problem, unfortunately, it does not always have the easiest solution.这是一个常见问题,不幸的是,它并不总是有最简单的解决方案。 Hopefully, this information will help you and others arrive at the best implementation that suits your needs.希望这些信息能帮助您和其他人找到适合您需求的最佳实施方案。 Disclaimer: if you have the option or capability to add IMAP to your pop3, it certainly makes things more manageable.免责声明:如果您可以选择或能力将 IMAP 添加到您的 pop3,它肯定会让事情变得更易于管理。

Gmail has its own Pop3 implementation, and with that said, not all of this is relevant to other pop3 providers Here is the lifecycle of the issue and some information that can help you manage it: Gmail 有自己的 Pop3 实现,话虽如此,并非所有这些都与其他 pop3 提供商相关 以下是问题的生命周期以及一些可以帮助您管理它的信息:

You connect to the pop3 server either in NORMAL mode or RECENT mode.您可以在 NORMAL 模式或 RECENT 模式下连接到 pop3 服务器。 This puts the "session" on the pop server into a "transaction state".这将 pop 服务器上的“会话”置于“事务状态”。 Recent mode is used by prefixing the username on connection with "recent:" + Username.最近模式是通过在连接时为用户名添加前缀“最近:”+ 用户名来使用的。 Recent mode will return the last 30 days of email on the server.最近模式将返回服务器上最近 30 天的电子邮件。 Note* this will supersede the UIDL command which I will touch on below.注意* 这将取代我将在下面介绍的 UIDL 命令。 Ie recent mode will return all 30 days worth of email if they have not been removed.即最近模式将返回所有 30 天的电子邮件,如果他们没有被删除。 Since it always returns the last 30 days, if you have multiple clients, they will all receive the same information in recent mode.由于它总是返回最近 30 天,如果你有多个客户端,他们都会在最近模式下收到相同的信息。

Normal mode is the default.正常模式是默认模式。 Normal mode will respect the limitations of the commands you choose to use.正常模式将尊重您选择使用的命令的限制。 UIDL will return a chunk of roughly 250 of the oldest emails on the server. UIDL 将返回服务器上大约 250 封最早的电子邮件。 If you have 500 emails on the server, and you do not remove any, UIDL will return the id and Unique Identifier for those first 250 emails regardless, so you may not be aware of the new 250. The caveat here is as follows, GMAIL has an option on the web console where you configure pop, to "Enable pop from now on".如果您在服务器上有 500 封电子邮件,并且您没有删除任何电子邮件,UIDL 无论如何都会返回前 250 封电子邮件的 id 和唯一标识符,因此您可能不知道新的 250。这里的警告如下,GMAIL在 Web 控制台上有一个选项,您可以在其中配置 pop,以“从现在开始启用 pop”。 By selecting that and saving, the timestamp at that moment will be used by the pop server to "refresh" the oldest time.通过选择并保存,pop 服务器将使用当时的时间戳来“刷新”最早的时间。 Therefore UIDL will start returning messages back you from that point on up until you reach the 250 mark again (assuming you have not removed them).因此,UIDL 将从那时起开始向您返回消息,直到您再次达到 250 标记(假设您尚未删除它们)。

It is important to note that the transaction state exists until you issue the QUIT command.请务必注意,事务状态一直存在,直到您发出 QUIT 命令。 Upon issuing that command the server enters the "Update" state, where it will begin issuing the updates you requested, like DELETE commands, or popping them after they have been downloaded.发出该命令后,服务器进入“更新”状态,它将开始发出您请求的更新,例如 DELETE 命令,或在下载后弹出它们。 Until QUIT is issued successfully, nothing will be deleted and the server state does not change.在成功发出 QUIT 之前,不会删除任何内容并且服务器状态不会改变。

STAT command will show you the number of emails in the pop3 stack, that are on your server. STAT 命令将显示您服务器上的 pop3 堆栈中的电子邮件数量。

RETR command will retrieve, or download the email, but it is not marked as downloaded until you successfully end the session RETR 命令将检索或下载电子邮件,但在您成功结束会话之前不会将其标记为已下载

UIDL which many developers use to retrieve the message numbers and unique identifiers is very useful if you maintain the state of the server and pop the email.如果您维护服务器的状态并弹出电子邮件,许多开发人员用来检索消息编号和唯一标识符的 UIDL 非常有用。 UIDL will only ever return the oldest 250-ish (I have seen 251-255) emails. UIDL 只会返回最旧的 250 封(我见过 251-255 封)电子邮件。 If you are constantly polling for new email, this is dangerous if email hasn't been removed.如果您不断轮询新电子邮件,如果电子邮件尚未删除,这将是危险的。 ALSO!还! if you need to delete email, make sure the GMAIL setting to, Keep a copy in my inbox, is configured in the web console, so that you have access to those emails as a backup.如果您需要删除电子邮件,请确保在 Web 控制台中配置 GMAIL 设置为在我的收件箱中保留副本,以便您可以访问这些电子邮件作为备份。

LIST command would solve your problem in normal mode for getting more than 250 emails back, (note: you still need to maintain an id file locally to cross-check incoming mail in order to know that it is new or old)... HOWEVER: this command also returns mail from the SENT box, which for many, is not a viable solution. LIST 命令可以解决您在正常模式下收到超过 250 封电子邮件的问题,(注意:您仍然需要在本地维护一个 id 文件来交叉检查收到的邮件,以便知道它是新的还是旧的)......但是:此命令还会从 SENT 框中返回邮件,这对许多人来说不是一个可行的解决方案。

Hints:提示:

If you are managing the inbox quickly and effectively and do not believe 250 to be a limiting factor in your process, UIDL and RETR will work.如果您正在快速有效地管理收件箱,并且不认为 250 是您流程中的限制因素,那么 UIDL 和 RETR 将起作用。

If you will not be able to keep your inbox below 250 but also need access to new email, AND you do not expect the inbox to grow to outrageous size and the performance is not concerning, RECENT mode should work.如果您无法将收件箱保持在 250 以下,但还需要访问新电子邮件,并且您不希望收件箱增长到令人发指的大小并且性能无关紧要,那么最近模式应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM