Commit c8bb1e8f authored by Adrián Ribao's avatar Adrián Ribao

improved email options

parent 607a420c
......@@ -27,6 +27,14 @@ Add the URLs to urls.py:
# Django users
url(r'^{{ app_name }}/', include('{{ app_name }}.urls')),
Usage
=====
Import the notification
Send it:
Indices and tables
==================
......
......@@ -20,14 +20,25 @@ class EmailBackend(NotificationBackendBase):
* subject
* template_name
* from_email
* bcc
"""
name = 'email'
from_email = None
bcc = []
def __init__(self, subject, template_name, *args, **kwargs):
super(EmailBackend, self).__init__(*args, **kwargs)
self.subject = subject
self.template_name = template_name
def get_from_email(self):
from_email = self.from_email or settings.DEFAULT_FROM_EMAIL
return from_email
def get_bcc_recipients(self):
return self.bcc
def get_tree_from_html(self, html):
parser = etree.HTMLParser()
tree = etree.parse(StringIO(html), parser)
......@@ -95,7 +106,9 @@ class EmailBackend(NotificationBackendBase):
msg = EmailMultiAlternatives(
subject=subject,
body=text_content,
to=recipients)
from_email= self.get_from_email(),
to=recipients,
bcc=self.get_bcc_recipients())
msg.attach_alternative(html_content, "text/html")
msg.send()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment