Skip to content

Instantly share code, notes, and snippets.

@davidmintz
Last active April 17, 2019 16:33
Show Gist options
  • Save davidmintz/2a85bf2e52c74859df1fd270178c93ab to your computer and use it in GitHub Desktop.
Save davidmintz/2a85bf2e52c74859df1fd270178c93ab to your computer and use it in GitHub Desktop.
note-to-self: how to delete everything in an inbox (Python)
#!/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