Skip to main content

Send emails with Django template system

Project description

==========
Django-Mail-Templated
==========
:Info: Send emails using Django template system
:Author: Artem Rizhov (https://github.com/artemrizhov)

Overview
=================
This is a tiny wrapper around standard EmailMessage class and send_mail()
function. Just pass the template_name and context as first parameters, and use
it as usually.

Installation
=================
Run::

$ pip install django-mail-templated

And register the app in your settings file::

INSTALLED_APPS = (
...
mail_templated
)

Usage
=================
Write a template to send a plain text message. Note that first and last \n\r
will be removed::

{% block subject %}
Hello {{ user.name }}
{% endblock %}

{% block body %}
This is a plain text message.
{% endblock %}

Or for html message::

{% block subject %}
Hello {{ user.name }}
{% endblock %}

{% block html %}
This is an <strong>html</strong> message.
{% endblock %}

Or for multipart message just use both blocks::

{% block subject %}
Hello {{ user.name }}
{% endblock %}

{% block body %}
This is a plain text message.
{% endblock %}

{% block html %}
This is an <strong>html</strong> message.
{% endblock %}

Or forget some block to set it manually later with EmailMessage class::

{% block body %}
This is a plain text message.
{% endblock %}

Now you can send it::

from mail_templated import send_mail
send_mail('email/hello.tpl', {'user': user}, from_email, [user.email])

Or if you wish to add more control over message creating then user the class::

from mail_templated import EmailMessage
message = EmailMessage('email/hello.tpl', {'user': user}, to=[user.email])
# ... attach a file, etc
message.send()

That's all. Please create an issue at GitHub if you have any notes,
...or just email :)

Project details


Release history Release notifications

History Node

2.6.5

History Node

2.6.2

History Node

2.6.1

History Node

2.6.0

History Node

2.5.0

History Node

2.4.7

History Node

2.4.6

History Node

2.4.5

History Node

2.4.4

History Node

2.4.3

History Node

2.4.2

History Node

2.4.1

History Node

2.4.0

History Node

2.3.0

History Node

2.2.1

History Node

2.2.0

History Node

2.1.0

History Node

2.0.0

History Node

1.0.0

History Node

0.2.2

This version
History Node

0.2.1

History Node

0.2.0

History Node

0.1.2

History Node

0.1.1

History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django-mail-templated-0.2.1.tar.gz (2.9 kB) Copy SHA256 hash SHA256 Source None May 6, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page