Skip to main content

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",
    verbose=True,  # prints real-time logs to the terminal
)

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",
    verbose=True,
)

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 button
  • feedback_request.html — feedback request with link
  • announcement.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 .env file
  • UsersFileError — malformed JSON or invalid user entries
  • TemplateError — 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

Metadata

Release files for mail-senderpy 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mail-senderpy 0.1.4
File Size Uploaded Provenance Actions
mail_senderpy-0.1.4.tar.gz 14.4 kB With provenance Details for mail_senderpy-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mail-senderpy 0.1.4
File Interpreter ABI Platform Actions
mail_senderpy-0.1.4-py3-none-any.whl Python 3 none any Details for mail_senderpy-0.1.4-py3-none-any.whl

Total release size: 27.0 kB

Release files / mail_senderpy-0.1.4.tar.gz

Download URL mail_senderpy-0.1.4.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ec29039708b11acf3b066eaf65f8ecce16ccda7e5775ff1c83430051cf20b1a2
BLAKE2b-256 checksum
How to use checksums
19421bfe04152de69dd66e3cfcd7ae8161e2f10c143fb9b21af43abaa8767ccd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / mail_senderpy-0.1.4-py3-none-any.whl

Download URL mail_senderpy-0.1.4-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb151fb2589abb7daa93d68fc995e6803febd3f4aeea08deb62799e6752b3349
BLAKE2b-256 checksum
How to use checksums
c196a95f54b03927a764074ed6afac7fddfb726142779d322a876f8751b1094d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Security for mail-senderpy 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mail_senderpy-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page