I want to send HTML-emails, using Django templates like this:
<html>
<body>
hello <strong>{{username}}</strong>
your account activated.
<img src="mysite.com/logo.gif" />
</body>
I can't find anything about send_mail
, and django-mailer only sends HTML templates, without dynamic data.
How do I use Django's template engine to generate e-mails?
Best Answer
From the docs, to send HTML e-mail you want to use alternative content-types, like this:
You'll probably want two templates for your e-mail - a plain text one that looks something like this, stored in your templates directory under
email.txt
:and an HTMLy one, stored under
email.html
:You can then send an e-mail using both those templates by making use of
get_template
, like this: