使用python imaplib“删除”来自Gmail的电子邮件? [英] Using python imaplib to "delete" an email from Gmail?

查看:1059
本文介绍了使用python imaplib“删除”来自Gmail的电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以使用imaplib删除电子邮件吗?

解决方案

使用 store (代表连接的 IMAP4 对象)的方法来设置 r'\Deleted'标记您要删除的消息号,如文档显示的示例;那么 expache 方法实际执行所有删除这样标记。



默认情况下,Gmail的IMAP实现具有微妙的不同语义,但如果您希望可以调整它的行为更像是一个传统的IMAP实现(上述序列的工作原理) - 基本上您必须启用高级IMAP控件实验室,然后按照我给出的URL的说明完全符合您所希望的IMAP语义(实际删除而不是归档已删除邮件,等待或不等待清除等等)。


Can you delete emails with imaplib? If so how?

解决方案

Use the store method (of the IMAP4 object representing your connection) to set the r'\Deleted' flag on the message number you want to delete, as the example in the docs show; then the expunge method to actually perform all deletions so marked.

Gmail's implementation of IMAP has subtly different semantics, by default, but if you want you can tweak it to behave much more like a traditional IMAP implementation (where the above sequence works) -- basically you have to enable the "Advanced IMAP Controls" lab, then follow the instructions at the URL I gave to get exactly the IMAP semantics you desire (physically deleting rather than archiving "deleted" mails, waiting or not for expunge, and so forth).

这篇关于使用python imaplib“删除”来自Gmail的电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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