Skip to content

wdroz/unsubscribe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

🚀 Email Unsubscribe Magic ✨

Hey there! Welcome to the ultimate tool in your digital arsenal against those pesky spam attacks - your very own Email Unsubscribe Wizard 🧙‍♂️! This Jupyter Notebook is more than just a bunch of code; it's your ticket to a cleaner, more serene inbox 📥.

Tired of endless spam emails clogging up your digital world? Annoyed by subscriptions you don't remember signing up for? We've got you covered! This tool dives into the abyss of your Spam folder and emerges with all those hidden unsubscribe links. It's like a treasure hunt, but instead of gold, you're finding peace of mind 🏝️.

This Python notebook processes emails from a specified .mbox file (particularly the Spam folder from a Gmail Takeout export) and sends unsubscribe requests to unique links found in these emails. It only processes emails sent within a specified number of days (default is the last 10 days)

limitation: This only work for news letters with direct links to the unsubscriptions

Project Structure

Your folder should be structured as follows:

❯ tree
.
├── README.md
├── Takeout
│   ├── Mail
│   │   └── Spam.mbox
│   └── archive_browser.html
├── takeout-20231206T082003Z-001.zip
└── unsub.ipynb

Prerequisites

pip install notebook requests tqdm ipywidgets

Usage

  1. Set Up Your .mbox File: Place your .mbox file in the correct directory (Takeout/Mail/Spam.mbox).

  2. Configure the Notebook: Edit the mbox_path variable in the notebook to point to your .mbox file. If you want to process emails from a different time range, modify the days variable (set to None to process all emails).

  3. Run the notebook: Open the notebook using Python.

jupyter notebook unsub.ipynb
  • Run each cell in the Jupyter Notebook sequentially.
  • You can execute the cells by selecting each and pressing Shift + Enter, or by using the 'Run' button in your Jupyter interface.

tips, for gmail, you can use this to get your data

Notebook Overview

  • find_unsubscribe_links: This function extracts unsubscribe links from the email content. It searches for URLs that contain the word 'unsubscribe'.

  • send_unsubscribe_request: This function sends an HTTP GET request to each unsubscribe link. It includes a custom Firefox user-agent in the request header.

  • is_recent: This function determines if an email is within the specified date range. It's used to filter emails by date, processing only those that were sent within the last days (default is 10).

  • Main loop: The script iterates through the .mbox file, processing only recent emails based on the days parameter. For each email, it extracts and collects unsubscribe links, avoiding duplicates. It then uses a thread pool to send unsubscribe requests concurrently to each unique link.

About

unsubscribe from all news letter from mbox files, no need to connect to anything

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published