Last active
September 4, 2015 20:41
-
-
Save ochronus/7ed5a01042d007024a52 to your computer and use it in GitHub Desktop.
Delete messages from flooded labels
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
import imaplib | |
EMAIL_ADDRESS = '[email protected]' | |
PASSWORD = 'nope nope nope' | |
FOLDER = 'This_is_a_parent_label/this_is_a_sublabel' | |
while True: | |
try: | |
mail = imaplib.IMAP4_SSL('imap.gmail.com') | |
mail.login(EMAIL_ADDRESS, PASSWORD) | |
mail.select(FOLDER) | |
mail.store("1:*", '+X-GM-LABELS', '\\Trash') | |
mail.expunge() | |
except imaplib.IMAP4.abort as e: | |
print "Imap abort, restarting for the rest of the mails: {msg}".format(msg=str(e)) | |
continue | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment