我应该使用哪个库通过 Python 脚本下载 Gmail 电子邮件的副本?
What library should i use to download a copy of Gmail emails through Python script?
在 python 脚本中,我希望能够连接到 gmail 服务器,然后将我所有的电子邮件下载到一个 .mbox 文件中。这可能吗?如果是这样,使用什么图书馆,我可以从哪里得到它?谢谢
标准 imaplib is working fine for me. Another standard library mailbox 也可能有用。
imaplib 来自 Python 标准库。
import imaplib
gmail = imaplib.IMAP4_SSL('imap.gmail.com')
gmail.login('username@gmail.com', 'password')
...
mbox format usually means just that the messages are catenated after each other, with the caveat that each line that starts with From
needs to be escaped with >
, very easy to write out by hand from Python script, though also supported by standard library with mailbox.mbox
在 python 脚本中,我希望能够连接到 gmail 服务器,然后将我所有的电子邮件下载到一个 .mbox 文件中。这可能吗?如果是这样,使用什么图书馆,我可以从哪里得到它?谢谢
标准 imaplib is working fine for me. Another standard library mailbox 也可能有用。
imaplib 来自 Python 标准库。
import imaplib
gmail = imaplib.IMAP4_SSL('imap.gmail.com')
gmail.login('username@gmail.com', 'password')
...
mbox format usually means just that the messages are catenated after each other, with the caveat that each line that starts with From
needs to be escaped with >
, very easy to write out by hand from Python script, though also supported by standard library with mailbox.mbox