Created
October 17, 2019 22:59
-
-
Save jeena/6f510fdd8f05f0b7b512e23aad8ea9a1 to your computer and use it in GitHub Desktop.
Delete all emails in GMail
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 python2 | |
import gmail # from https://github.com/charlierguo/gmail | |
from datetime import datetime, timedelta, date | |
print "Logging in inte GMail ...", | |
g = gmail.login("foo", "test") | |
print "done." | |
d = date(2018, 10, 30) | |
while True: | |
print "Getting mails for %s ..." % d, | |
emails = g.inbox().mail(on=d) | |
print "deleting %d ..." % len(emails), | |
for email in emails: | |
email.delete() | |
# seems to take at least 2 seconds | |
# with my 1.000.000 mails it'll take over 20 days | |
print("done.") | |
d = d - timedelta(days=1) | |
g.logout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment