django-mail-templatedSend emails with Django template system | |
Download |
django-mail-templated Ranking & Summary
Advertisement
- License:
- MIT/X Consortium Lic...
- Price:
- FREE
- Publisher Name:
- Artem Rizhov
- Publisher web site:
- https://github.com/artemrizhov/
django-mail-templated Tags
django-mail-templated Description
django-mail-templated 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.InstallationRun:: pip install -e git+git://github.com/artemrizhov/django-mail-templated.git#egg=mail_templatedAnd register the app in your settings file:: INSTALLED_APPS = ( ... mail_templated )UsageWrite 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, )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=) # ... attach a file, etc message.send()Product's homepage
django-mail-templated Related Software