如何解决从网络邮件中删除邮件-不适用于所有文件夹
def process_webmail():
Box = imaplib.IMAP4_SSL(server)
Box.login(username,password)
print("Connected to webmail")
_tuple = Box.list()
if len(_tuple) <= 0:
return
before_date = (datetime.date.today() - datetime.timedelta(30)).strftime("%d-%b-%Y")
for folder in _tuple[1]:
_folder_name = folder.split('\"/\"')
f = _folder_name[1].strip().strip('\"')
if f.lower() == "inBox":
pass
else:
Box.select(f)
# typ,data = Box.search(None,'ALL')
typ,'(BEFORE {0})'.format(before_date))
if data != ['']:
for num in data[0].split():
Box.store(num,'+FLAGS','\\Deleted')
print(Box.expunge())
Box.close()
Box.logout()
我们有2种类型的文件夹。 1)创建文件夹并将邮件手动复制到该文件夹。 2)已应用过滤器以复制邮件。
以上代码在1上有效,而在2的情况下仅将电子邮件标记为已删除。不知道是什么问题。有人请帮助我了解这个问题。
Roundcube是正在使用的网络邮件。
解决方法
以下代码有效。错误放置的.expunge()
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin: /usr/bin:/sbin:/bin:/snap/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。