Django-Template-Mail
==========
:Info: A Django application to send email using django's templating system
:Author: Benoît Bar (http://github.com/benoitbar, http://twitter.com/benoitbar)
Get started
===========
Installing
----------
::
pip install django-template-mail
Configure your mail backend
---------------------------
django-template-mail ships with same backends as Django (https://docs.djangoproject.com/en/dev/topics/email/#email-backends). Just replace **django.core.mail** by **templatemail** ::
EMAIL_BACKEND = 'templatemail.backends.smtp.EmailBackend'
Convert HTML into plain text
----------------------------
By default, django-template-backend use a minimalist process to convert HTML into plain text. I suggest you to use **html2text** (https://github.com/aaronsw/html2text) ::
EMAIL_HTML2TEXT = 'html2text.html2text'
You can also write your own method and use it ::
EMAIL_HTML2TEXT = 'your.module.yourhtml2textmethod'
Sending emails
==============
To send email with django-template-mail you simply should use the method described in the Django documentation (https://docs.djangoproject.com/en/dev/topics/email/) and replacing the **message** attribute as a tuple **('directory_template/template.html', {'key': 'value'}, context_instance)** ::
from django.core.mail import send_mail
send_mail(
'Welcome',
(
'mail/welcome.html',
{
'username': request.user.username,
'full_name': request.user.get_full_name(),
'signup_date': request.user.date_joined
}
),
'from@example.com',
['to@example.com'],
fail_silently=False
)
django-template-mail looked in django template directories/loaders ::
<p>Hi {{full_name}},</p>
<p>
You just signed up using:
<ul>
<li>username: {{username}}</li>
<li>join date: {{signup_date}}</li>
</ul>
</p>
<p>Thanks!</p>
Metadata
Release files for django-template-mail 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-template-mail-0.1.tar.gz | 4.3 kB | Without provenance | Details for django-template-mail-0.1.tar.gz |
Release files / django-template-mail-0.1.tar.gz
| Download URL | django-template-mail-0.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92e117ecc178f6ac242bfdb078d2d1ce6832a913486274dc8dc842665a7b3a88
|
|
BLAKE2b-256 checksum How to use checksums |
168fff3c6745cea51316f248f03bb7dd0c948ac92ca8bcb32925c6818cf4036d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-template-mail 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.