Async bulk email sender with Jinja2 templates and CLI
Project description
mail-senderpy
Bulk email sender with Jinja2 templates and CLI.
Send personalized emails to a list of users using any SMTP provider (Gmail, Outlook, AWS SES, SendGrid, etc.).
Installation
pip install mail-senderpy
Quick Start
Python API
from mail_senderpy import send_message
result = send_message(
env_path=".env",
users_path="users.json",
template_path="template.html",
)
print(result)
# {"success": 18, "failed": 2, "errors": [{"email": "...", "error": "..."}]}
Or use send_message_async in an async context:
from mail_senderpy import send_message_async
result = await send_message_async(
env_path=".env",
users_path="users.json",
template_path="template.html",
)
CLI
mail-senderpy send --env .env --users users.json --template template.html
Options:
| Flag | Default | Description |
|---|---|---|
--env |
.env |
Path to .env file |
--users |
users.json |
Path to users JSON file |
--template |
template.html |
Path or built-in template name |
--subject |
Hello, {{name}}! |
Email subject (Jinja2 supported) |
--delay |
10.0 |
Seconds between sends |
Configuration
Create a .env file with your SMTP credentials:
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
EMAIL_ADDRESS=your@email.com
EMAIL_PASSWORD=app_password
SMTP_TLS=true
All fields are required except SMTP_TLS (defaults to true).
Users JSON Format
[
{"email": "user1@example.com", "name": "Rahul"},
{"email": "user2@example.com", "name": "Priya"}
]
Each object's fields are available as Jinja2 template variables.
Templates
Custom Templates
Create an HTML file with Jinja2 placeholders:
<h1>Hello {{ name }}!</h1>
<p>We're reaching out to you at {{ email }}.</p>
Built-in Templates
Pass a built-in template name instead of a file path:
marketing_email.html— promotional layout with CTA buttonfeedback_request.html— feedback request with linkannouncement.html— announcement layout
mail-senderpy send --template marketing_email.html
Return Value
{
"success": 18,
"failed": 2,
"errors": [
{"email": "user@test.com", "error": "SMTP authentication failed"}
]
}
Error Handling
The library validates all inputs before sending and raises descriptive errors:
ConfigError— missing or invalid.envfileUsersFileError— malformed JSON or invalid user entriesTemplateError— template file not found
from mail_senderpy import send_message, MailSenderError
try:
result = send_message(env_path=".env", users_path="users.json", template_path="template.html")
except MailSenderError as e:
print(f"Error: {e}")
print(f"Details: {e.details}")
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mail_senderpy-0.1.3.tar.gz.
File metadata
- Download URL: mail_senderpy-0.1.3.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6de21b19363e05b39d61f1d9799767910f3f1502a75872eabb5c6b5cb15d03f4
|
|
| MD5 |
d2016af1efafcd7b35faaa1e87af2159
|
|
| BLAKE2b-256 |
b1979c0972a61cc9beaa35875c897c1903292b7ad821e5158a0a953a51eed8b9
|
Provenance
The following attestation bundles were made for mail_senderpy-0.1.3.tar.gz:
Publisher:
publish.yml on extinctsion/mail-sender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mail_senderpy-0.1.3.tar.gz -
Subject digest:
6de21b19363e05b39d61f1d9799767910f3f1502a75872eabb5c6b5cb15d03f4 - Sigstore transparency entry: 1101724505
- Sigstore integration time:
-
Permalink:
extinctsion/mail-sender@9b9ebeb907ab3f4be89cd2bf07fa8a01e3e2cbab -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/extinctsion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9b9ebeb907ab3f4be89cd2bf07fa8a01e3e2cbab -
Trigger Event:
push
-
Statement type:
File details
Details for the file mail_senderpy-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mail_senderpy-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f9d2124518a8c81e74b651b6b82a985c18b053235f90d35e28ab49386cef12c
|
|
| MD5 |
38db96064673810293daa7c5346d9749
|
|
| BLAKE2b-256 |
91a3b69934e2bda03816533f095a519bb787efec5ecf6418988fd76b0c5d3cba
|
Provenance
The following attestation bundles were made for mail_senderpy-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on extinctsion/mail-sender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mail_senderpy-0.1.3-py3-none-any.whl -
Subject digest:
5f9d2124518a8c81e74b651b6b82a985c18b053235f90d35e28ab49386cef12c - Sigstore transparency entry: 1101724506
- Sigstore integration time:
-
Permalink:
extinctsion/mail-sender@9b9ebeb907ab3f4be89cd2bf07fa8a01e3e2cbab -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/extinctsion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9b9ebeb907ab3f4be89cd2bf07fa8a01e3e2cbab -
Trigger Event:
push
-
Statement type: