Last active
April 17, 2019 16:33
-
-
Save davidmintz/2a85bf2e52c74859df1fd270178c93ab to your computer and use it in GitHub Desktop.
note-to-self: how to delete everything in an inbox (Python)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from imapclient import IMAPClient | |
server = IMAPClient('imap.example.com', use_uid=True) | |
server.login('[email protected]', '******') | |
select_info = server.select_folder('INBOX') | |
ids = server.search() | |
print("expunging {} messages...".format(len(ids))) | |
server.delete_messages(ids) | |
server.expunge() | |
server.logout() | |
print("done.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment