MailWatch is a small daemon that watches a mailbox on a mail server over IMAP and takes actions based upon the messages it receives.
The primary motivation behind this is the shitbag spammers who pull my email from various mailing lists and Git hosting sites where my email address is sitting in the logs.
- Python 3.13 or newer
- uv
Clone the repository and sync the environment:
uv syncThis creates a virtual environment and installs the project along with its development dependencies.
Run MailWatch with uv run (or activate the virtual environment first):
uv run mailwatch --host imap.example.com --username user@example.com --password secretAvailable options:
| Option | Description | Default |
|---|---|---|
--host |
Mail server host | required |
--port |
Mail server port | 993 |
--username |
Login username | required |
--password |
Login password | required |
Every option can also be provided through an environment variable. Command-line flags take precedence over environment variables:
| Option | Environment variable |
|---|---|
--host |
MAILWATCH_HOST |
--port |
MAILWATCH_PORT |
--username |
MAILWATCH_USERNAME |
--password |
MAILWATCH_PASSWORD |
For example:
export MAILWATCH_HOST=imap.example.com
export MAILWATCH_USERNAME=user@example.com
export MAILWATCH_PASSWORD=secret
uv run mailwatchRun uv run mailwatch --help for the full list of options.
See docs/tests.md.
Probably. Yeah, I'm putting this up where anyone can see it and this literally has my mailbox rules within it, especially for my spam detection. Look, if you come across this and decide it's time to set siege to my mailbox I'm kinda screwed. I accept that.
But I figure it's nice enough to have this up here for other folks to see and reference so oh well.