大收件箱上的imaplib.select:命令的参数过多 [英] imaplib.select on big inbox: Too many arguments for command

查看:204
本文介绍了大收件箱上的imaplib.select:命令的参数过多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过python脚本访问Gmail中的电子邮件.我使用的代码如下:

I am trying to access to my emails in Gmail from a python script. The code I use is the following:

import imaplib
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login("username","password")
m.select("[Gmail]/All Mail")

在python 2中运行此代码时,它工作正常,我得到了所有电子邮件的列表.在python 3悬停器中,它失败并显示错误

When running this code in python 2, it works fine, I get the list of all my emails. In python 3 hoverer it fails with the error

>>> m.select("[Gmail]/All Mail")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.2/imaplib.py", line 674, in select
    typ, dat = self._simple_command(name, mailbox)
  File "/usr/lib/python3.2/imaplib.py", line 1121, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python3.2/imaplib.py", line 957, in _command_complete
    raise self.error('%s command error: %s %s' % (name, typ, data))
imaplib.error: SELECT command error: BAD [b'[CLIENTBUG] Too many arguments for command']

我做了一些测试.它在其他文件夹(例如收件箱")中也能正常工作,在该文件夹中,我仅收到400封电子邮件(与所有邮件"中的6000个邮件相比).

I have done a bit of testing. It works fine on other folder such as "Inbox" where I get only 400 emails (vs 6000 in "All Mail").

这是与列表大小有关的问题吗?为什么在python 2和3中有什么不同?

Is it a problem related to the size of the list ? Why is it different in python 2 and 3 ?

谢谢

推荐答案

尝试使用m.select('"[Gmail]/All Mail"'),以便传递双引号.

Try using m.select('"[Gmail]/All Mail"'), so that the double quotes get transmitted.

我怀疑imaplib不能正确引用该字符串,因此服务器获取的外观类似于两个参数:[Gmail]/AllMail.

I suspect imaplib is not properly quoting the string, so the server gets what looks like two arguments: [Gmail]/All and Mail.

这篇关于大收件箱上的imaplib.select:命令的参数过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆