[英]IMAP command UID FETCH: Too long argument
我正在將 imaplib (imap4) 與 Python 3.7.0 一起使用,我正在嘗試獲取一個大文件夾,我得到了
FETCH command error: BAD [b'Error in IMAP command UID FETCH: Too long argument (0.001 + 0.122 + 0.122 secs).']
我正在使用的代碼如下
def run(self, verifyQueue):
config = json.load(open("config.json", "r+"))
client = IMAPClient(host=config.get('imapHost'))
while True:
try:
client.login(config.get('imapUsername'), config.get('imapPassword'))
client.select_folder(config.get('imapFolder'))
self.log('Loaded')
while True:
try:
client.idle()
responses = client.idle_check(timeout=30)
if responses:
client.idle_done()
messages = client.search("UNSEEN")
for uid, message_data in client.fetch(messages, "RFC822").items():
emailMSG = email.message_from_bytes(message_data[b"RFC822"])
這非常適用於小文件夾,但這個文件夾有幾千封電子郵件
拆分消息似乎已經解決了問題
messages = client.search("UNSEEN")
for i in range(0, len(messages), 500):
for uid, message_data in client.fetch(messages[i:i + 500], "RFC822").items():
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.