Skip to content

nex2hex/django-email-multi-related

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-email-multi-related

Send HTML emails with embedded images in Django from templates. Required Django >= 1.4 and BeautifulSoup4 with lxml http://www.crummy.com/software/BeautifulSoup/bs4/doc/#parser-installation parser for automatically generat text version of email.

Send emails using django templates

Add emailmultirelated to settings.INSTALLED_APPS

from emailmultirelated.mail import EmailMultiRelated
email = EmailMultiRelated('email title', to=['[email protected]'])
email.set_body_template('email_template.html', {})
email.send()

Example of email_template.html

{% load emailmultirelated %}

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
  <body>
    <img src="{% email_embedded_media "path_to_image_in_media_root_dir.png" %}" alt="" />
    <img src="{% email_embedded_static "path_to_image_in_static_root_dir.png" %}" alt="" />
  </body>
</html>

Send emails using Jinja2 templates

Required Jinja2

from emailmultirelated.mail import EmailMultiRelated
email = EmailMultiRelated('email title', to=['[email protected]'])
email.set_body_template('email_template.html', {}, using='jinja')
email.send()

Example of email_template.html

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
  <body>
    <img src="{% email_embedded_media "path_to_image_in_media_root_dir.png" %}" alt="" />
    <img src="{% email_embedded_static "path_to_image_in_static_root_dir.png" %}" alt="" />
  </body>
</html>

How write HTML Emails

About

Send HTML emails with embedded images in Django

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages