Skip to main content

A Django oriented templated / transaction email abstraction

Project description

==========
Django-Templated-Email
==========
:Info: A Django oriented templated email sending class
:Author: Bradley Whittington (http://github.com/bradwhittington, http://twitter.com/darb)

Overview
=================
django-templated-email is oriented towards sending templated emails
intended for use with transactional mailers (ala mailchimp, silverpop,
etc.), but currently comes out of the box with a backend class which
uses django's templating system, and django's core.mail functions.

The send_templated_email method can be thought of as the render_to_response
shortcut for email.

Getting going - installation
=============

Installing::

pip install templated_email

You can add the following to your settings.py (but it works out the box)::

TEMPLATED_EMAIL_BACKEND = 'templated_email.backends.vanilla_django.TemplateBackend'

# For the django back-end specifically
TEMPLATED_EMAIL_DJANGO_SUBJECTS = {
'welcome':'Welcome to my website',
}

Getting going - sending your template emails
=============

Example usage using vanilla_django TemplateBackend backend

Python to send mail::

from templated_email import send_templated_email
send_templated_email(
template_name='welcome',
from_email='from@example.com',
recipient_list=['to@example.com'],
context={
'username':request.user.username,
'full_name':request.user.get_full_name(),
'signup_date':request.user.date_joined
}
)

Which looks in django template directories/loaders for
*templated_email/welcome.txt* ::

Hey {{full_name}},

You just signed up for my website, using:
username: {{username}}
join date: {{signup_date}}

Thanks, you rock!

It will also use *templated_email/welcome.html* for the html part
of the email allowing you to make it so much pretty. It is plausible
that one day there will be support for attachments and inline mime / images

Using PostageApp:
=============

To use the PostageApp (http://postageapp.com) send method, you will need to install python-postageapp::

pip install -e git://github.com/bradwhittington/python-postageapp.git#egg=postageapp

And add the following to your settings.py::

TEMPLATED_EMAIL_BACKEND = 'templated_email.backends.postageapp_backend.TemplateBackend'

POSTAGEAPP_API_KEY = 'yourapikey'

#If you are already using django-postageapp:

EMAIL_POSTAGEAPP_API_KEY = POSTAGEAPP_API_KEY

Using MAILCHIMP STS:
=============

To use the MailChimp STS send method, you will need to install mailsnake (please note, until the main mailsnake has STS support, you need to use my fork)::

pip install -e git://github.com/bradwhittington/mailsnake.git#egg=mailsnake

And add the following to your settings.py::

TEMPLATED_EMAIL_BACKEND = 'templated_email.backends.mailchimp_sts.TemplateBackend'

MAILCHIMP_API_KEY = 'yourapikey'

# For the django back-end specifically
TEMPLATED_EMAIL_MAILCHIMP = {
'welcome':{
'subject':'Welcome to my website',
'track_opens':True,
'track_clicks':False,
'tags':['my','little','pony'],
}
}


.. _Django: http://djangoproject.com

Project details


Download files

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

Source Distribution

django-templated-email-0.2.tar.gz (5.7 kB view details)

Uploaded Source

File details

Details for the file django-templated-email-0.2.tar.gz.

File metadata

File hashes

Hashes for django-templated-email-0.2.tar.gz
Algorithm Hash digest
SHA256 c4ccede5d9c7d85ca408a725858ae637934945034076691a02149ec86a470db3
MD5 1dc8a2bc0ae4c082762570b65c90612d
BLAKE2b-256 fb784bd98a6b0dfbf4ca84458619b2e8fe83da3103b8f3c5af0e5e1e3f9a03b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page