Send emails using Django template system
This is a tiny wrapper around the standard EmailMessage class and send_mail() function that provides an easy way to create email messages using the Django template system. Just pass template_name and context as the first parameters then use as normal.
Features
Built with OOP, KISS and flexibility in mind. Really small and simple, but yet full-featured (I hope).
Extends and mimics the built-in Django’s EmailMessage and send_mail(). Compatible as much as possible.
Fully supports Django template system including template inheritance (thanks to BradWhittington for the note about the problem).
Supports any possible template engines and loaders.
Supports serialisation (thanks to arjandepooter).
Fully covered with tests.
Tested with Django 1.4-1.9.
Compatible with Python 3.
Documentation
Quick start
Run:
pip install django-mail-templated
And register the app in your settings file:
INSTALLED_APPS = (
...
'mail_templated'
)
Create template:
{% extends "mail_templated/base.tpl" %}
{% block subject %}
Hello {{ user.name }}
{% endblock %}
{% block body %}
{{ user.name }}, this is a plain text message.
{% endblock %}
{% block html %}
{{ user.name }}, this is an <strong>html</strong> message.
{% endblock %}
Send message:
from mail_templated import send_mail
send_mail('email/hello.tpl', {'user': user}, from_email, [user.email])
Advanced usage:
from mail_templated import EmailMessage
message = EmailMessage('email/hello.tpl', {'user': user}, from_email,
to=[user.email])
# TODO: Add more useful commands here.
message.send()
More useful info and examples at http://django-mail-templated.readthedocs.org
Metadata
Release files for django-mail-templated 2.6.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-mail-templated-2.6.5.tar.gz | 11.9 kB | Without provenance | Details |
Release files / django-mail-templated-2.6.5.tar.gz
| Download URL | django-mail-templated-2.6.5.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ce4b415d97f50587d9f9ff395b01e919539e1734b6b6f84385f4d2e6d3db7b5
|
|
BLAKE2b-256 checksum How to use checksums |
a865989c7a65dd77f3eff8aa4ac656e3e8cc735259448319848df4e92a7fcd6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-mail-templated 2.6.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.