A powerful desktop application for analyzing, organizing, and cleaning up your Gmail inbox. Built with Java and JavaFX, this application runs completely locally on your computer while securely connecting to Gmail via OAuth 2.0.
- Smart Scanning: Scan your Gmail inbox and analyze emails efficiently
- Sender Grouping: View all emails grouped by sender with detailed statistics
- Storage Analytics: See exactly how much storage each sender is using
- Email Categorization: Automatically categorize emails (Promotional, Newsletter, Social, Important, etc.)
- Bulk Delete: Delete all emails from specific senders with one click
- Selective Deletion: Choose individual emails to delete
- Safe Deletion: Emails are moved to trash (not permanently deleted)
- Unsubscribe Helper: One-click access to unsubscribe links
- Quick Search: Search by sender name or email address
- Advanced Filtering: Filter by category, date, or size
- Real-time Updates: See changes reflected immediately
- Total Email Count: Track total number of scanned emails
- Storage Usage: Monitor total storage used by emails
- Visual Tables: Easy-to-read tables with sorting capabilities
- Progress Tracking: Real-time progress bars during operations
Before running the application, ensure you have:
-
Java 17 or higher installed on your system
- Download from: https://adoptium.net/ or https://www.oracle.com/java/technologies/downloads/
- Verify installation:
java -version
-
Maven 3.6 or higher (for building from source)
- Download from: https://maven.apache.org/download.cgi
- Verify installation:
mvn -version
-
Gmail Account with API access enabled
This is a one-time setup required before using the application:
- Go to Google Cloud Console
- Click "Create Project" or select an existing project
- Give your project a name (e.g., "Email Cleanup App")
- Click "Create"
- In your project, go to "APIs & Services" > "Library"
- Search for "Gmail API"
- Click on it and press "Enable"
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- If prompted, configure the OAuth consent screen:
- Choose "External" user type
- Fill in required fields (App name, support email)
- Add your email as a test user
- Click "Save and Continue" through all steps
- Back in "Create OAuth client ID":
- Choose "Desktop app" as application type
- Give it a name (e.g., "Email Cleanup Desktop")
- Click "Create"
- Click "Download JSON" to download your credentials
- Rename the downloaded file to
credentials.json - Place it in the root directory of the application (same folder as
pom.xml)
The file should look like this:
{
"installed": {
"client_id": "YOUR_CLIENT_ID.apps.googleusercontent.com",
"project_id": "your-project-id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "YOUR_CLIENT_SECRET",
"redirect_uris": ["http://localhost"]
}
}# Clone or download the project
cd smart-email-cleanup
# Run the application
mvn clean javafx:run# Build the project
mvn clean package
# Run the JAR file
java -jar target/smart-email-cleanup-1.0.0-jar-with-dependencies.jar# Build with JPackage (requires JDK 17+)
jpackage --input target \
--name "Email Cleanup Assistant" \
--main-jar smart-email-cleanup-1.0.0-jar-with-dependencies.jar \
--main-class com.emailcleanup.EmailCleanupApp \
--type dmg # Use 'exe' for Windows, 'deb' for Linux- Launch the application
- Authenticate with Gmail:
- Click "Account" > "Login"
- Your browser will open automatically
- Sign in to your Google account
- Grant permissions when prompted
- A success message will appear
- Scan your emails:
- Click "File" > "Scan Emails"
- Enter number of emails to scan (start with 500 for testing)
- Wait for the scan to complete
- Analyze and cleanup:
- Browse senders by storage usage
- Click on a sender to view all their emails
- Use "Delete All from Selected Sender" or select individual emails
- Click "Unsubscribe" to open unsubscribe links
smart-email-cleanup/
├── src/
│ └── main/
│ ├── java/
│ │ └── com/
│ │ └── emailcleanup/
│ │ ├── EmailCleanupApp.java # Main application
│ │ ├── model/
│ │ │ ├── Email.java # Email data model
│ │ │ └── SenderStats.java # Sender statistics model
│ │ ├── service/
│ │ │ ├── GmailAuthService.java # Gmail OAuth authentication
│ │ │ ├── EmailScannerService.java # Email scanning logic
│ │ │ ├── EmailCategorizerService.java # Email categorization
│ │ │ ├── EmailActionService.java # Delete/unsubscribe actions
│ │ │ └── DatabaseService.java # H2 database operations
│ │ └── ui/
│ │ └── MainWindow.java # JavaFX UI
│ └── resources/
│ └── logback.xml # Logging configuration
├── pom.xml # Maven configuration
├── credentials.json # Gmail API credentials (you create this)
└── README.md # This file
Generated folders:
├── data/ # H2 database files
├── logs/ # Application logs
├── tokens/ # OAuth tokens (auto-generated)
└── target/ # Compiled files
- Language: Java 17
- UI Framework: JavaFX 19
- Build Tool: Maven
- Database: H2 (embedded)
- Gmail Integration: Google Gmail API
- Authentication: OAuth 2.0
- HTML Parsing: JSoup
- Logging: SLF4J + Logback
- GmailAuthService: Handles OAuth 2.0 authentication flow
- EmailScannerService: Fetches emails from Gmail API
- EmailCategorizerService: Categorizes emails using pattern matching
- DatabaseService: Manages local H2 database for email metadata
- EmailActionService: Performs delete and unsubscribe operations
- MainWindow: JavaFX user interface
Gmail API → EmailScannerService → EmailCategorizerService → DatabaseService → UI
↓
EmailActionService → Gmail API
By default, you can scan any number of emails. However, Gmail API has rate limits:
- 250 quota units per user per second
- 1 billion quota units per day
The application automatically handles rate limiting.
Email metadata is stored in: ./data/emailcleanup.mv.db
To reset the database, simply delete the data/ folder.
Application logs are stored in: ./logs/email-cleanup.log
Solution: Make sure credentials.json is in the root directory of the project.
Solutions:
- Check your internet connection
- Verify Gmail API is enabled in Google Cloud Console
- Ensure you added your email as a test user
- Delete the
tokens/folder and try authenticating again
Solution: The OAuth callback uses port 8888. Close any application using this port or change it in GmailAuthService.java (line with setPort(8888)).
Solution: Install OpenJFX:
# Ubuntu/Debian
sudo apt-get install openjfx
# Fedora
sudo dnf install java-openjfxSolutions:
- Verify Java 17+ is installed:
java -version - Check JavaFX is available:
mvn javafx:run - Review logs in
logs/email-cleanup.log
- Local First: All email metadata is stored locally on your computer
- Secure Authentication: Uses OAuth 2.0 (no password storage)
- Read-Only by Default: Application doesn't modify emails without your explicit action
- No Telemetry: No data is sent to third parties
- Open Source: Review the code yourself
The application requests these Gmail permissions:
- gmail.modify: Required to read emails and move them to trash
- View your email messages and settings
- Delete emails
The application does not:
- Send emails
- Access your password
- Share your data with anyone
- Start Small: Begin with 500-1000 emails to test
- Batch Processing: The app processes in batches of 50 for efficiency
- Database Cleanup: Periodically delete the
data/folder to start fresh - Selective Scanning: Focus on specific date ranges if needed
- Gmail Only: Currently supports Gmail only (not Outlook, Yahoo, etc.)
- Desktop Only: No mobile version available
- Single Account: One Gmail account at a time
- API Limits: Subject to Gmail API rate limits
Potential features for future versions:
- Multi-account support
- Email templates and auto-replies
- Advanced filtering and rules
- Export reports to PDF/CSV
- Schedule automatic cleanups
- Email attachment manager
- Support for other email providers
This is a local-first application. To contribute:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available for personal and commercial use.
For issues, questions, or suggestions:
- Check the Troubleshooting section above
- Review application logs in
logs/ - Verify Gmail API setup is correct
- Check internet connectivity
- Initial release
- Gmail integration with OAuth 2.0
- Email scanning and analysis
- Sender grouping and statistics
- Bulk delete functionality
- Unsubscribe link detection
- Email categorization
- Local H2 database storage
- JavaFX desktop UI
Built with ❤️ for productivity and privacy
Enjoy your clean inbox! 📧✨