Poplib 无法正常工作?

发布于 2024-07-14 19:21:05 字数 181 浏览 17 评论 0原文

我想从我的 gmail 收件箱中获取所有邮件,但我面临两个问题。

  1. 它不会获取所有电子邮件(根据 stat 函数中的计数)
  2. 它获取的电子邮件的顺序是随机的。

我不确定是否是 poplib 或 gmail pop 服务器的问题。

我在这里缺少什么?

I want to get all the messages from my gmail inbox, but I am facing 2 problems.

  1. It does not get all the emails, (as per the count in stat function)
  2. The order of emails it get is random.

I am unsure if its the problem with poplib or gmail pop server.

What am I missing here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

烟花易冷人易散 2024-07-21 19:21:05

你的代码是什么样的? 使用 poplib,您可以决定下载消息的顺序和数量。 poplib 文档 中的代码应该可以工作:

import getpass, poplib

M = poplib.POP3('localhost')
M.user(getpass.getuser())
M.pass_(getpass.getpass())
numMessages = len(M.list()[1])
for i in range(numMessages):
    for j in M.retr(i+1)[1]:
        print j

What does your code look like? Using poplib, you're able to decide on the order and number of the messages downloaded. The code from the poplib documentation should work:

import getpass, poplib

M = poplib.POP3('localhost')
M.user(getpass.getuser())
M.pass_(getpass.getpass())
numMessages = len(M.list()[1])
for i in range(numMessages):
    for j in M.retr(i+1)[1]:
        print j
心不设防 2024-07-21 19:21:05

您还可以尝试 imaplib 模块,因为 GMail 还提供通过 IMAP 协议访问电子邮件的功能。

You can also try imaplib module since GMail also provides access to email via IMAP protocol.

她比我温柔 2024-07-21 19:21:05

为什么不尝试使用libgmail

Why don't you try to use libgmail?

岁月苍老的讽刺 2024-07-21 19:21:05

这是 Gmail 的问题:https://mail.google.com/support /bin/answer.py?answer=13291

尝试使用最近的:[电子邮件;protected] 作为您的电子邮件地址。 至少您上个月的所有邮件都会按正确的顺序排列。

It's the problem of gmail: https://mail.google.com/support/bin/answer.py?answer=13291

Try to use recent:[email protected] as your email address. At least you'll have all your last month mail in correct order.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文