Skip to content

Latest commit

 

History

History
55 lines (34 loc) · 2.26 KB

README.md

File metadata and controls

55 lines (34 loc) · 2.26 KB

This is a little utility to identify the most heavy email senders & offenders in your gmail account. Outputs by ranked frequency the most common senders, domains, and email addresses. Output is intended to help you manually clean up your gmail, unsubscribe, and/or create filters.

I wrote this to identify emails to delete, so there are settings to ignore specific emails that come from senders I like.

One time setup

1. Setup Gmail API Access

Follow steps in "Set up your environment" section of these instructions: https://developers.google.com/gmail/api/quickstart/python#set-up-environment

You should have downloaded a credentials.json file to the same directory as this README.

This will give you permission to access your own gmail. No one else.

2. Setup your python project

  1. Install pipenv

     pip install pipenv
    
  2. Create a python3 venv (it will be created under ~/.virtualenvs/)

     pipenv --three
    
  3. Activate your venv

     pipenv shell
    
  4. Install dependencies, which includes the gmail python client.

     pipenv install
    
  5. Copy config.py.sample to config.py and edit config.py as desired. You can revisit these settings whenever.

     cp config.py.sample config.py
    

Run the script

Edit config.py repeatedly as desired and rerun script with:

python3 analyze.py

The first time you run this you will need to accept the oauth consent form (say yes to procced even though unsafe), which will save a token.json file to your working dir for only you and only your APIs. To speed up testing while you figure out your desired config settings, use a small year range or 1 year batches. Note that Google rate limits now (vs when this was first written) so there is some intentional throttling added in 2025 to avoid tripping the blocks and getting locked out.

Reference Guides