简体   繁体   English

IMAP取得实体太慢

[英]IMAP fetch body too slow

Trying to get emails from IMAP(gmail) and struggling with the last part. 尝试从IMAP(gmail)获取电子邮件,并为最后一部分苦苦挣扎。

If I fetch just message headers, for a 85 messages in my inbox, it took 3 seconds: 如果仅获取邮件标题,则收件箱中有85条邮件,花了3秒钟:

imap.fetch(message_ids, '(BODY.PEEK[HEADER.FIELDS (FROM TO CC SUBJECT DATE)])')

But if i try to fetch the email body, it takes ~3 minutes: 但是,如果我尝试获取电子邮件正文,则大约需要3分钟:

imap.fetch(message_ids, '(RFC822)')

or 要么

imap.fetch(message_ids, '(BODY.PEEK[TEXT])')

or 要么

imap.fetch(message_ids, 'RFC822.TEXT')

Already tried to set TCP_NODELAY as some thread suggested here. 已经尝试将TCP_NODELAY设置为此处建议的某些线程。 Same problem with imapClient lib and Twisted imap4 module imapClient lib和Twisted imap4模块存在相同问题

Any thoughts? 有什么想法吗?

All of those will retrieve the full MIME content of the message, which can be quite large if they include attachments, and will take quite a while. 所有这些都将检索消息的完整MIME内容,如果包含附件,则可能会很大,并且会花费一些时间。

If you fetch BODYSTRUCTURE , you can parse the format/structure of the message, and get an idea of the size before you download it, and where exactly the main "body" part is. 如果获取BODYSTRUCTURE ,则可以解析消息的格式/结构,并在下载消息之前先了解大小,以及确切的“主体”部分在哪里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM