mailsweep is a terminal UI for finding the heaviest senders in your Gmail account and bulk-moving mail to Trash safely.
It is optimized for large inboxes:
- incremental Gmail sync
- local mailbox cache
- lazy message drilldown loading
- background sender prefetch
- sortable and filterable sender leaderboard
- safer bulk trash with age filters
mailsweep scans your Gmail mailbox, groups messages by sender, and ranks senders by storage usage.
From the UI, you can:
- see which senders take the most space
- sort by total size, message count, or sender name
- filter senders quickly
- drill into a sender’s messages
- select individual messages to move to Trash
- bulk-move all messages from a sender to Trash
- restrict bulk actions to messages older than 30, 90, 180, or 365 days
Messages are moved to Gmail Trash, not hard-deleted immediately.
- Go
1.25+ - a Gmail account
- a Google Cloud OAuth desktop client with Gmail API enabled
mailsweep expects credentials.json in one of these locations:
~/.mailsweep/credentials.json./credentials.json
You can create it like this:
- Open
https://console.cloud.google.com - Create a Google Cloud project
- Enable the Gmail API
- Open
APIs & Services -> OAuth consent screen - Create an
Externalapp - Add your Gmail address as a test user
- Open
APIs & Services -> Credentials - Create an
OAuth client ID - Choose
Desktop app - Download the JSON credentials file
Move it into place:
mkdir -p ~/.mailsweep
mv ~/Downloads/client_secret_*.json ~/.mailsweep/credentials.jsongo run .Or build a binary first:
go build -o mailsweep .
./mailsweepOn first run, mailsweep opens a browser-based OAuth flow and stores your token locally in:
~/.mailsweep/token.json
It also stores:
- mailbox cache in
~/.mailsweep/cache.json - UI preferences in
~/.mailsweep/prefs.json
The first screen is the sender leaderboard.
It shows:
- sender email
- message count
- total mailbox space used
- a relative usage bar
- age-preview counts once sender details are prefetched
Keys:
↑↓/j k: move selectionenter: open sender drilldownD: bulk-move the selected sender’s mail to Trash/: start filtering senderss: cycle sort moder: refresh mailboxq: quit
Sorting cycles through:
- total size
- message count
- sender name
Filtering matches sender email or sender display text.
The drilldown screen shows messages for one sender.
Keys:
↑↓/j k: move selectionspace: toggle a messagea: select all / clear alld: move selected messages to Trashesc: go back
Before a trash action runs, mailsweep shows a confirmation step.
Keys:
y: confirmn/esc: cancel←→/h l: switch Yes/No[/]: change the age filter
Age filter options:
- all messages
- older than 30 days
- older than 90 days
- older than 180 days
- older than 365 days
The app avoids expensive rescans where possible:
- refresh uses Gmail history-based incremental sync when available
- sender message bodies are not fetched during the initial scan
- drilldown data is loaded only when needed
- selected/nearby senders are prefetched in the background
- prefetch cache is bounded in memory
Format and build:
gofmt -w .
go build ./...mailsweepuses Gmail modify scope- bulk actions move messages to
TRASH - messages may remain recoverable through Gmail Trash depending on Gmail retention behavior
See LICENSE.