{ "info": { "author": "SF Software limited t/a Pebble", "author_email": "sysadmin@talktopebble.co.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "==========\nDjango-Templated-Email\n==========\n:Info: A Django oriented templated email sending class\n:Author: Bradley Whittington (http://github.com/bradwhittington, http://twitter.com/darb)\n:Tests: .. image:: https://api.travis-ci.org/bradwhittington/django-templated-email.png\n\nOverview\n=================\n\nThis is a fork of django-templated-email so we can keep a version in pypi\nwhich works with the latest version of Django.\n\ndjango-templated-email is oriented towards sending templated emails\nintended for use with transactional mailers (with support for MailchimpSTS,\nand PostageApp), but as a default with a backend class which uses django's\ntemplating system, and django's core.mail functions. The library supports\ntemplate inheritence, adding cc'd and bcc'd recipients, configurable\ntemplate naming and location, with easy switching between backends/providers.\n\nThe send_templated_email method can be thought of as the render_to_response\nshortcut for email.\n\nGetting going - installation\n=============\n\nInstalling::\n\n pip install django-templated-email\n\nYou can add the following to your settings.py (but it works out the box)::\n\n TEMPLATED_EMAIL_BACKEND = 'templated_email.backends.vanilla_django.TemplateBackend'\n\n # You can use a shortcut version\n TEMPLATED_EMAIL_BACKEND = 'templated_email.backends.vanilla_django'\n\n # You can also use a class directly\n from templated_email.backends.vanilla_django import TemplateBackend\n TEMPLATED_EMAIL_BACKEND = TemplateBackend\n\n\nSending templated emails\n=============\n\nExample usage using vanilla_django TemplateBackend backend\n\nPython to send mail::\n\n from templated_email import send_templated_mail\n send_templated_mail(\n template_name='welcome',\n from_email='from@example.com',\n recipient_list=['to@example.com'],\n context={\n 'username':request.user.username,\n 'full_name':request.user.get_full_name(),\n 'signup_date':request.user.date_joined\n },\n # Optional:\n # cc=['cc@example.com'],\n # bcc=['bcc@example.com'],\n # headers={'My-Custom-Header':'Custom Value'},\n # template_prefix=\"my_emails/\",\n # template_suffix=\"email\",\n )\n\nIf you would like finer control on sending the email, you can use **get_templated_email**, which will return a django **EmailMessage** object, prepared using the **vanilla_django** backend::\n\n from templated_email import get_templated_mail\n get_templated_mail(\n template_name='welcome',\n from_email='from@example.com',\n to=['to@example.com'],\n context={\n 'username':request.user.username,\n 'full_name':request.user.get_full_name(),\n 'signup_date':request.user.date_joined\n },\n # Optional:\n # cc=['cc@example.com'],\n # bcc=['bcc@example.com'],\n # headers={'My-Custom-Header':'Custom Value'},\n # template_prefix=\"my_emails/\",\n # template_suffix=\"email\",\n )\n\nYou can also **cc** and **bcc** recipients using **cc=['example@example.com']**. Some backends have other parameters you can override, see below.\n\nYour template\n-------------\n\nThe templated_email/ directory needs to be the templates directory.\n\nThe backend will look in *my_app/templates/templated_email/welcome.email* ::\n\n {% block subject %}My subject for {{username}}{% endblock %}\n {% block plain %}\n Hi {{full_name}},\n\n You just signed up for my website, using:\n username: {{username}}\n join date: {{signup_date}}\n\n Thanks, you rock!\n {% endblock %}\n\nIf you want to include an HTML part to your emails, simply use the 'html' block ::\n\n {% block html %}\n
Hi {{full_name}},
\n\nYou just signed up for my website, using:\n
Thanks, you rock!
\n {% endblock %}\n\nYou can globally override the template dir, and file extension using the following variables in settings.py ::\n\n TEMPLATED_EMAIL_TEMPLATE_DIR = 'templated_email/' # use '' for top level template dir, ensure there is a trailing slash\n TEMPLATED_EMAIL_FILE_EXTENSION = 'email'\n\nFor the **vanilla_django** and **mailchimp_sts** backends you can set a value for **template_prefix** and **template_suffix** (or use the less backend-portable **template_dir** / **file_extension**) for every time you call **send_templated_mail**, if you wish to store a set of templates in a different directory. Remember to include a trailing slash.\n\nPlease note / Warning about template inheritence\n-------------\nThere is very basic support for template inheritence (using **{% extends ... %}** in templates). You will run into issues if you use **{{block.super}}**, and will result in blank parts of emails.\n\nLegacy Behaviour\n----------------\n\nThe 0.2.x version of the library looked in django template directories/loaders\nfor **templated_email/welcome.txt** ::\n\n Hey {{full_name}},\n\n You just signed up for my website, using:\n username: {{username}}\n join date: {{signup_date}}\n\n Thanks, you rock!\n\nIt will use **templated_email/welcome.html** for the html part\nof the email allowing you to make it so much pretty.\n\nFuture Plans\n------------\n\nSee https://github.com/bradwhittington/django-templated-email/issues?state=open\n\nUsing django_templated_email in 3rd party applications:\n=============\n\nIf you would like to use django_templated_email to handle mail in a reusable application, you should note that:\n\n* Your calls to **send_templated_mail** should set a value for **template_dir**, so you can keep copies of your app-specific templates local to your app (although the loader will find your email templates if you store them in *