![](/img/trans.png)
[英]Use IMAP4 in python to move mail from a mailbox to another mailbox
[英]Python IMAP4 select mailbox name contain space character, error
我正在使用Python imaplib.IMAP4
連接到Google電子郵件。 除了我使用包含空格字符的郵箱名稱的IMAP4.select()
方法外,其他所有操作都可以。 假設我的郵箱名稱是“ Gama Sutra”。
當我執行imap.select('[Gmail]/Gama Sutra')
時,出現以下錯誤:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imaplib.py", line 682, in select
typ, dat = self._simple_command(name, mailbox)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imaplib.py", line 1133, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imaplib.py", line 964, in _command_complete
raise self.error('%s command error: %s %s' % (name, typ, data))
imaplib.error: SELECT command error: BAD [b'Could not parse command']
我該如何解決?
它應該自動執行此操作,但只需將文件夾名稱用雙引號引起來即可:
imap.select('"[Gmail]/Gama Sutra"')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.