lettermint-django¶
An unofficial Django email backend for the Lettermint API. Open source, not affiliated with Lettermint. Maintained by zzinnovate.
Quick start¶
Available on PyPI. Install and configure:
pip install lettermint-django
import os
EMAIL_BACKEND = "lettermint_django.LettermintEmailBackend"
LETTERMINT_API_KEY = os.getenv("LETTERMINT_API_KEY")
That's it. All Django send_mail(), EmailMessage, and EmailMultiAlternatives calls now route through Lettermint.
Features¶
- No SMTP required: sends via the Lettermint HTTP API
- Django-native: works with all standard Django mail helpers
- Per-message routing: override the route per email via
extra_headers - HTML support:
EmailMultiAlternativeswithtext/htmlalternative works out of the box - Minimal dependencies: only
lettermint(official SDK) on top of Django
Common operations¶
from django.core.mail import send_mail, EmailMessage, EmailMultiAlternatives
import os
# Simple email
send_mail(
subject="Hello",
message="Plain text body.",
from_email="noreply@example.com",
recipient_list=["user@example.com"],
)
# HTML email
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()
# Per-message route override
msg = EmailMessage(
subject="Password reset",
body="Click the link...",
from_email="noreply@example.com",
to=["user@example.com"],
)
msg.extra_headers["X-Lettermint-Route"] = "transactional"
msg.send()