This release is a pre-release and may not be stable for production use.
mail_monitor
A small utility to watch an IMAP mailbox for new email and react to it in Python. It has no dependencies outside the Python standard library.
It has two pieces:
EmailClient— logs into an IMAP server and fetches emails (all, unseen, or already-seen), optionally filtered to a sender whitelist.EmailMonitor— a backgroundThreadthat pollsEmailClienton an interval and calls a callback for each new email.
Install
pip install mail_monitor
Usage
from mail_monitor import EmailMonitor
mail = "me@example.com"
password = "app-password" # use an app password, not your real password
monitor = EmailMonitor(mail, password, time_between_checks=30)
def new_email(email):
print(email["sender"], email["subject"], email["payload"])
monitor.on_new_email = new_email
monitor.start() # runs in a background thread
Each email is delivered as a dict: {"sender", "email", "payload", "ts", "subject"}.
payload is always plain text: a multipart message's text/plain part is
used when present, and an HTML-only message is stripped of markup with a
small stdlib parser.
IMAP configuration
EmailMonitor and EmailClient default to Gmail (imap.gmail.com:993, folder
inbox). Gmail requires IMAP access to be enabled and an
app password — a regular Google
account password will not work. For other providers, pass address and
port for their IMAP server.
EmailMonitor(mail, password, address="imap.example.com", port=993)
Never hardcode credentials in source — load them from environment variables or a secrets file that is not committed.
License
Apache-2.0.
Metadata
Release files for mail-monitor 0.5.1a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mail_monitor-0.5.1a2.tar.gz | 10.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mail_monitor-0.5.1a2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.3 kB
Release files / mail_monitor-0.5.1a2.tar.gz
| Download URL | mail_monitor-0.5.1a2.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50e8c642dad234e0081cd118d06efe4be831306f2c42e829931c4a6fe2a78826
|
|
BLAKE2b-256 checksum How to use checksums |
b70f4782e8c1a30b8456ba7aa037c95636f932c903d7e84b191e00bb50c5df1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / mail_monitor-0.5.1a2-py3-none-any.whl
| Download URL | mail_monitor-0.5.1a2-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b27ebab2509d4b784ed5754d507dc2c22badd27ba9647ae2481aa9f432653d9b
|
|
BLAKE2b-256 checksum How to use checksums |
943b72050fa75beccee533b4f22895744b5ce6f11f118531af2670e1d43191f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|