Skip to content
Send emails based on a Django template
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
email_template
tests
.gitignore
LICENSE
README.md
setup.py

README.md

Send emails with Django templates

Usage:

Create a template

myemail.html

{% block subject %}Subject{% endblock %}

{% block text %}Hello from {{ name }}{% endblock %}

{% block recipients %}x@z.com, y@z.com{% endblock %}

Send the template:

from email_template.email import send

send("myemail.html", dict(name=name))

This will send a text/plain email message using django.core.mail.EmailMessage to the specified recipients.

You can optionally add an html block to send a multipart email, or specify the html block only, which sends a text/html email.

Providing a request context

You can provide the request argument to have your email rendered using RequestContext instead.

def myview(request):
    send("myemail.html", dict(name=name), request=request)
    return HttpResponse("ok")

Install:

Install using pip:

pip install django-email-template

Install from github:

pip install -e git+git://github.com/prestontimmons/django-email-template.git#egg=email-template

Running tests

Use the runtests.py command in the tests directory.

You can’t perform that action at this time.