https://github.com/bennycode/gmail-email-purger
Python program to delete all emails from Google Mail.
https://github.com/bennycode/gmail-email-purger
Last synced: 3 months ago
JSON representation
Python program to delete all emails from Google Mail.
- Host: GitHub
- URL: https://github.com/bennycode/gmail-email-purger
- Owner: bennycode
- Created: 2025-07-17T15:25:15.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-07-17T15:53:26.000Z (10 months ago)
- Last Synced: 2025-07-17T18:03:20.871Z (10 months ago)
- Language: Python
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gmail Email Deletion
> [!WARNING]
> This script will permanently delete ALL emails and folders from your Gmail account. Use with extreme caution!
## What This Script Does
This Python script connects to your Google Mail account via IMAP and:
- **Deletes ALL emails** from every folder in your Gmail account
- **Deletes ALL folders** (except system folders that can't be deleted)
- **Permanently removes emails** by emptying trash after each batch
## Prerequisites
1. **Gmail App Password**: You need to generate an App Password (not your regular Gmail password)
- Go to [Google App Passwords](https://myaccount.google.com/apppasswords)
- Generate a new App Password for "Mail"
- Use this password in the script
2. **IMAP Access**: Ensure IMAP is available in your Google Mail settings
- Go to Gmail Settings → [Forwarding and POP/IMAP](https://mail.google.com/mail/u/0/#settings/fwdandpop)
- Contact your workspace administrator if IMAP is not enabled (see [Turn POP & IMAP on or off for users](https://support.google.com/a/answer/105694?hl=en&sjid=12332642361958922417-EU))
## Setup and Usage
### Option 1: GitHub Codespaces
[](https://codespaces.new/bennycode/gmail-email-purger)
1. Click the "Open in GitHub Codespaces" button above
2. Wait for the environment to load
3. Dependencies install automatically
4. Script will run automatically
### Option 2: Local Setup
```bash
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# Install required dependencies
pip install -r requirements.txt
# Run the script
python main.py
```