del_gmail
del_gmail copied to clipboard
Python script to delete mails from Gmail that match a keyword
Delete all the Emails from Gmail that match a search keyword.
Why?
You cannot delete tens of thousands mails at once on Gmail UI. It will fail at last. So I write a script to do that.
Usage
- Install Google client library:
pip install --upgrade google-api-python-client oauth2client. - Goto Gmail's Python API quickstart page, click "ENABLE THE GMAIL API" button. Put the downloaded
credentials.jsonfile in the same directory of this project. - Run
python del_mail.py, it will open a webpage. Login to Gmail and click agree. - Input the keyword you want to delete. The script will show some mails that match the keyword. Press enter will delete all the mails that match the keyword.
Use Behind a Proxy
If Google is blocked in your country, you may what to use proxy for this script. An easy solution is to using proxychains-ng. Another note is open the login page manully and copy the verification code back to console. So the command is like:
proxychains4 -q python del_main.py --noauth_local_webserver