Categories
Python

Django: Sending HTML Only Email

Prior to Django 1.7 (currently in dev), we don’t have any option to pass html version of an email to “send_mail()” from django.core.mail module. Even in the newer version, you can pass html template as an alternative but you have to pass a plain text version as well. What if you want to send html version, only? This is what I did –

Now you would pass html as the message parameter. I use django templates with “render_to_string()” function from django.template.loader module.

Do you know any other, perhaps smarter way to accomplish this? Please share in the comments! 🙂

5 replies on “Django: Sending HTML Only Email”

Thanks, it is not nessesary complicated ourselves, this works so fine, thanks.

Comments are closed.