Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv
unsubscriber.log
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
530 changes: 322 additions & 208 deletions AutoUnsubscriber.py

Large diffs are not rendered by default.

Empty file added README.md
Empty file.
38 changes: 34 additions & 4 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
This program is an email auto-unsubscriber. Depending on your email provider and settings, it may require you to allow access to less secure apps.
# Auto Unsubscriber

It uses IMAP to log into your email. From there, it goes through every email with "unsubscribe" in the body, parses the HTML, and uses regex to search through anchor tags for keywords that indicate an unsubscribe link (unsubscribe, optout, etc). If it finds a match, it grabs the href link and puts the address and link in a list.
A Python utility that scans your email for newsletters and spam, finds unsubscribe links, and helps you bulk-unsubscribe and delete old emails.

After the program has a list of emails and links, for each address in the list, it gives the user the option to navigate to the unsubscribe link and to delete emails with unsubscribe in the body from the sender.

Once the program finishes going through the list, it gives the user the option to run the program again on the same email address, run it on a different email address, or quit the program.

## Features

* **Universal IMAP Support:** Auto-detects major providers (Gmail, Yahoo, Outlook, Zoho, etc.) and supports **manual entry** for custom domains or private servers.
* **Smart Parsing:** Scans email bodies for unsubscribe links using `BeautifulSoup`.
* **Safety First:**
* Runs in "Read Only" mode during the scanning phase.
* Requires explicit `DELETE` confirmation before removing any data.
* Opens links in small batches to prevent browser crashes.
* **High Performance:**
* Uses **Batch Fetching** (50 emails at a time) to prevent server timeouts.
* Uses **Batch Deletion** and single-pass `EXPUNGE` for maximum speed.
* **Interactive:** Review senders one by one or process them all in bulk.

## Prerequisites

* **Python 3.8+**
* **uv** (Recommended for dependency management) or `pip`.
* **App Password:** If you use 2FA (Gmail, Zoho, Yahoo, etc.), you must use an App-Specific Password, not your regular login password.

## Usage with `uv` (Recommended)

This project uses [`uv`](https://github.com/astral-sh/uv) for fast, isolated execution without needing to create manual virtual environments.

### 1. Clone or Download
Clone the repo

### 2. Install requirements
uv add -r requirements.txt

### 3. Run
uv run AutoUnsubscriber.py
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main():
print("Hello from autounsubscriber!")


if __name__ == "__main__":
main()
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[project]
name = "autounsubscriber"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"beautifulsoup4>=4.14.3",
"imapclient>=3.0.1",
"pyzmail36>=1.0.5",
"tqdm>=4.67.1",
]
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pyzmail36
imapclient
beautifulsoup4
tqdm
92 changes: 92 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.