Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

lettermint-django

PyPI version Tests codecov Python Version Django Version

An unofficial Django email backend for Lettermint. Drop it in as your EMAIL_BACKEND and all Django mail (send_mail(), EmailMessage, EmailMultiAlternatives) routes through the Lettermint API. Supports per-message routing, HTML emails, attachments, and reply-to headers with no changes to your existing email code. An optional tracking application records sent messages and delivery events through Lettermint webhooks.

Built and maintained by zzinnovate. Not affiliated with Lettermint.

Documentation

📖 View Full Documentation →

Requirements

  • Python 3.11+ (Django 6 requires Python 3.12+)
  • Django 4.2, 5.x, or 6.x
  • lettermint 2.0+

Install

pip install lettermint-django

# For development (includes testing tools)
pip install -e ".[dev]"

Quick start

import os

EMAIL_BACKEND = "lettermint_django.LettermintEmailBackend"
LETTERMINT_API_KEY = os.getenv("LETTERMINT_API_KEY")

That's it. All send_mail(), EmailMessage, and EmailMultiAlternatives calls in Django will now route through Lettermint.

Email tracking (optional)

Add the app, set the webhook secret and include the webhook URL to record every sent message and its delivery events (delivered, bounced, failed):

INSTALLED_APPS += ["lettermint_django"]
LETTERMINT_WEBHOOK_SECRET = os.getenv("LETTERMINT_WEBHOOK_SECRET")

# urls.py
path("", include("lettermint_django.urls")),
python manage.py migrate lettermint_django

Point a webhook in the Lettermint dashboard at /lettermint/message-events/ (change it with LETTERMINT_WEBHOOK_PATH). Query LmEmailMessage and LmEmailEvent, or connect to the lm_email_bounced signal. See the tracking guide.

Bulk sending

Send the same mail to many people, or a personalised mail to each of them, in batches through Lettermint's batch endpoint:

from lettermint_django.bulk import send_bulk_mail

result = send_bulk_mail(
    [{"email": g.email, "name": g.name, "link": g.invite_url} for g in guests],
    subject="{{ name }}, you are invited",
    text_template="emails/invite.txt",
    html_template="emails/invite.html",
    tag="invites",
)
result.sent_count, result.failed   # per-message outcome, with message ids

See the bulk sending guide.

Roadmap

This project is actively developed with a clear path toward v1.0.0. Our roadmap includes email tracking, bounce monitoring, and engagement analytics.

  • Current: v0.4.x (email backend, delivery tracking via webhooks, bulk sending)
  • Next: v0.5.0 (opens, clicks, analytics)
  • Planned: v1.0.0 (production-ready)

View the full roadmap →

Settings Reference

Setting Required Default Description
LETTERMINT_API_KEY Yes - Your project API token from the Lettermint dashboard
LETTERMINT_BASE_URL No SDK default Override the Lettermint API base URL
LETTERMINT_ROUTE No - Default route applied to all outgoing emails
LETTERMINT_BULK_ROUTE No - Route applied to bulk sends, overriding LETTERMINT_ROUTE for those messages
LETTERMINT_TIMEOUT No SDK default Request timeout in seconds
LETTERMINT_WEBHOOK_SECRET With tracking - Signing secret of your Lettermint webhook
LETTERMINT_WEBHOOK_PATH No lettermint/message-events/ Path of the webhook endpoint
LETTERMINT_BATCH_SIZE No 500 Messages per request for bulk sending

Per-message Route

Override the route for a specific message via extra_headers:

from django.core.mail import EmailMessage

msg = EmailMessage(
    subject="Password reset",
    body="Click the link...",
    from_email="noreply@example.com",
    to=["user@example.com"],
)
msg.extra_headers["X-Lettermint-Route"] = "app-priority"
msg.send()

HTML Emails

from django.core.mail import EmailMultiAlternatives

msg = EmailMultiAlternatives(
    subject="Welcome",
    body="Plain text fallback.",
    from_email="noreply@example.com",
    to=["user@example.com"],
)
msg.attach_alternative("<h1>Hello!</h1>", "text/html")
msg.send()

Contributing

Contributions are welcome. See CONTRIBUTING.md for development setup, testing, and workflow guidelines.

Security

See SECURITY.md for reporting vulnerabilities and best practices.

Credits

This package is built on top of the official lettermint Python SDK, which handles all API communication.

License

MIT. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lettermint_django-0.4.0b1.tar.gz (44.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lettermint_django-0.4.0b1-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file lettermint_django-0.4.0b1.tar.gz.

File metadata

  • Download URL: lettermint_django-0.4.0b1.tar.gz
  • Upload date:
  • Size: 44.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lettermint_django-0.4.0b1.tar.gz
Algorithm Hash digest
SHA256 bfa19058baafd5f0e9415af5aa10ed24867e921ba122b72cc55535f6e5cea7e8
MD5 d851c621b6b3e0382b74430ffa60073a
BLAKE2b-256 b25a6a545e38b441869b85e9bdaa3a0f4029a1c724fb15da46c130a5e4cccfec

See more details on using hashes here.

Provenance

The following attestation bundles were made for lettermint_django-0.4.0b1.tar.gz:

Publisher: publish.yml on zzinnovate/lettermint-django

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lettermint_django-0.4.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for lettermint_django-0.4.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 6500a09fbf32d41156d625e6c041e8b96c2bc02c4f8639eb1e93941c5a00ed60
MD5 63410cdb53ea42fb7541bf23d3f6c5f1
BLAKE2b-256 d1463b9559049907255c442c40825577acff5d6e0f8af2fe5e935628c9262f16

See more details on using hashes here.

Provenance

The following attestation bundles were made for lettermint_django-0.4.0b1-py3-none-any.whl:

Publisher: publish.yml on zzinnovate/lettermint-django

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.0b1 This release

2 files

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