Simple, secure bulk email — a local tool and Python library with optional AI personalization
pip install sahajmails==2.0.1 Copy PIP instructions
Personalized bulk email that runs on your machine.
Sahaj means simple and natural. So does this.
pip install sahajmails sahajmails That's it. A local web app opens. Load a spreadsheet, write your email, send.
Your contacts, your password and your drafts never leave your computer. There is no account, no server of ours, and no telemetry.
sahajmails init # starter files here sahajmails check contacts.csv -t email.md -s "Hi {{ first_name }}" sahajmails send contacts.csv -t email.md -s "Hi {{ first_name }}" --dry-run Or import it:
from sahajmails import send send(contacts="contacts.csv", template="email.md", subject="Hello {{ first_name }}") Writing the email Your spreadsheet columns become placeholders. Casing and spacing don't matter — {{ firstName }}, {{ first_name }} and {{ FIRST_NAME }} are the same column.
Hi {{ first_name | default("there") }}, {% if company %}I saw the news about {{ company }} — congratulations.{% endif %} The rest of this email is identical for everyone. Best, Sahaj default(...) matters: without it, a blank cell stops the send rather than quietly mailing "Hi ,". That is deliberate.
Wrap the one sentence you want personalized. Everything outside the block is byte-identical for every recipient — that is enforced by the design, not by asking the model nicely.
Hi {{ first_name }}, {% ai "opener" max_words=25 fallback="Hope your week is going well." %} One warm sentence about {{ company }}. No greeting, no exclamation marks. {% endai %} I'm writing because … The model receives only that instruction and that contact's variables. Output is capped, stripped of markup, and checked against your banned phrases. Anything that fails becomes your fallback. A flaky API can never block a send. You review every line before anything is sent, and your edits are used verbatim. Works with Claude, OpenAI, or any OpenAI-compatible endpoint — including Ollama and LM Studio running locally, so the "nothing leaves your machine" promise stays true.
The app binds 127.0.0.1 only. It is protected by a session token, a Host allowlist (which is what stops DNS-rebinding attacks that same-origin policy does not), CSRF headers, and a sandboxed template engine that escapes contact data so a spreadsheet can never inject markup into your mail. Passwords are kept in memory unless you explicitly ask to store them. Full detail in docs/security.md; report anything you find via SECURITY.md.
git clone https://github.com/sahajrajmalla/sahajmails.git cd sahajmails make install # needs pip >= 25.1 make check # ruff, mypy --strict, pytest See CONTRIBUTING.md. The whole test suite runs offline — there is a built-in SMTP stub and a fake AI backend, so you never need real credentials to develop.
email bulk-email email-marketing smtp gmail personalization mail-merge ai fastapi
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.




