Created
July 19, 2016 18:36
-
-
Save Roadmaster/94b89a32b40c8ef5ab469c9de056e274 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# This script will log into the specified IMAP server, select the INBOX, | |
# then just delete all the messages present there. | |
import imaplib | |
the_imap = imaplib.IMAP4_SSL("your-imap-server.com") | |
print(the_imap.login("your-login", "your-plaintext-password")) | |
print(the_imap.list()) | |
print(the_imap.select("INBOX")) | |
typ, data = the_imap.search(None, "ALL") | |
msg_set = data[0].split() | |
if msg_set: | |
msg_set_str = "%s:%s" % (msg_set[0], msg_set[-1]) | |
the_imap.store(msg_set_str, '+FLAGS', '\\Deleted') | |
the_imap.expunge() | |
print(the_imap.select("INBOX")) | |
the_imap.close() | |
the_imap.logout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment