A comprehensive tool for processing spam emails to help combat the spam problem. This tool automatically processes spam emails by attempting to unsubscribe, reporting to authorities, performing WHOIS lookups, and maintaining detailed logs.
- Automatic Unsubscribe: Finds and follows unsubscribe links (including RFC-compliant List-Unsubscribe headers)
- Authority Reporting: Reports spam to FTC, IC3, and APWG
- Company Reporting: Identifies impersonated companies and reports to their abuse contacts
- WHOIS Analysis: Performs domain analysis for sender domains
- Comprehensive Logging: Tracks all actions and maintains detailed metadata
.emlfiles (standard email format).msgfiles (Outlook format)
spam-email/
├── consume/ # Place email files here for processing
├── processed/ # Processed emails are moved here
├── logs/ # Detailed logs of all processing
├── spam-email.py # Main processing script
├── email_reporter.py # Email reporting utility
├── extract_emails.py # Apple Mail extraction helper
├── config.json # Configuration file
└── requirements.txt # Python dependencies
- Clone this repository
- Install dependencies:
pip install -r requirements.txt
- Copy spam email files (
.emlor.msg) to theconsume/directory - Run the processor:
python spam-email.py
- Check the
logs/directory for detailed results
If you're using Apple Mail on macOS:
-
Manual Method:
- Select spam emails in Apple Mail
- Right-click → "Save As..." → Choose "Raw Message Source" format
- Save as
.emlfiles to theconsume/directory
-
Helper Script (experimental):
python extract_emails.py
Edit config.json to customize settings:
{
"email_settings": {
"smtp_server": "smtp.gmail.com",
"smtp_port": 587,
"username": "your-email@gmail.com",
"password": "your-app-password",
"from_email": "your-email@gmail.com"
},
"reporting_settings": {
"enable_auto_unsubscribe": true,
"enable_authority_reporting": true,
"enable_company_reporting": true,
"max_unsubscribe_attempts": 3,
"request_timeout": 10
}
}- Extracts metadata (sender, subject, dates, headers)
- Parses email content (text and HTML)
- Identifies sender domain
- Finds unsubscribe links in email content
- Checks RFC-compliant List-Unsubscribe headers
- Attempts to unsubscribe via HTTP requests
- Logs all attempts and results
- Performs domain registration lookup
- Extracts registrar information
- Identifies abuse contacts
- Logs domain ownership details
- Scans content for known company names
- Matches against database of company abuse contacts
- Prepares reports for impersonated companies
Prepares reports for:
- FTC (Federal Trade Commission)
- IC3 (FBI Internet Crime Complaint Center)
- APWG (Anti-Phishing Working Group)
Built-in contacts for major companies:
- PayPal, Amazon, Apple, Microsoft
- Google, Facebook, eBay, Netflix
- UPS, FedEx, Wells Fargo, Chase
- Bank of America, and more
Detailed information about each processed email:
logs/email_metadata_YYYYMMDD_HHMMSS.json
Record of all actions performed:
logs/actions_taken_YYYYMMDD_HHMMSS.json
Daily summary of processing activity:
logs/summary_report_YYYYMMDD.json
Send reports via email to companies and authorities:
python email_reporter.pyThis requires email configuration in config.json.
Process multiple emails at once by placing them all in the consume/ directory and running the main script.
Add custom company abuse contacts in config.json:
{
"additional_company_contacts": {
"example-company": "abuse@example.com",
"another-company": "security@company.com"
}
}- Only attempts unsubscribe for legitimate-looking links
- Uses timeouts to prevent hanging
- Logs all attempts for review
- Only reports actual spam/phishing emails
- Includes proper context in reports
- Follows established reporting procedures
- All processing is done locally
- No email content is sent to external services (except for reporting)
- Logs can be reviewed before any reports are sent
-
Import Errors: Install missing dependencies with
pip install -r requirements.txt -
Permission Errors: Ensure the script has write access to the logs and processed directories
-
Email Format Issues: Ensure emails are saved in
.emlformat from your email client -
Network Timeouts: Adjust timeout settings in
config.json
Add logging verbosity by modifying the logging level in spam-email.py:
logging.basicConfig(level=logging.DEBUG)This tool is designed to help combat spam email. Contributions are welcome:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
- Additional email format support
- More authority reporting endpoints
- Machine learning spam classification
- GUI interface
- Integration with email clients
This tool is designed for processing emails you have received. Always comply with:
- Local laws regarding email processing
- Terms of service of reporting organizations
- Privacy regulations in your jurisdiction
Use responsibly and only for legitimate spam fighting purposes.
This project is open source. Please use it responsibly to help combat spam email.
Remember: The goal is to help reduce spam email for everyone. Use this tool responsibly and in accordance with all applicable laws and regulations.