{ "info": { "author": "Bradley Whittington", "author_email": "radbrad182@gmail.com", "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 :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "==============================\nDjango-Templated-Email\n==============================\n\n|GitterBadge|_ |PypiversionBadge|_ |PythonVersionsBadge|_ |LicenseBadge|_\n\n:Info: A Django oriented templated email sending class\n:Author: Bradley Whittington (http://github.com/bradwhittington, http://twitter.com/darb)\n:Tests: |TravisBadge|_ |CoverageBadge|_\n\n\nOverview\n=================\ndjango-templated-email is oriented towards sending templated emails.\nThe library supports template inheritance, adding cc'd and bcc'd recipients,\nconfigurable template naming and location.\n\nThe send_templated_email method can be thought of as the render_to_response\nshortcut for email.\n\nMake sure you are reading the correct documentation:\n\ndevelop branch: https://github.com/vintasoftware/django-templated-email/blob/develop/README.rst\n\nstable pypi/master: https://github.com/vintasoftware/django-templated-email/blob/master/README.rst\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.. code-block:: python\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.. code-block:: python\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.. code-block:: python\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']**.\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.. code-block:: python\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.. code-block:: python\n\n {% block html %}\n
Hi {{full_name}},
\n\nYou just signed up for my website, using:\n
Thanks, you rock!
\n {% endblock %}\n\nThe plain part can also be calculated from the HTML using `html2text