Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Adrián Ribao
Notifintime
Commits
c8bb1e8f
Commit
c8bb1e8f
authored
Mar 05, 2013
by
Adrián Ribao
Browse files
improved email options
parent
607a420c
Changes
2
Hide whitespace changes
Inline
Side-by-side
docs/source/index.rst
View file @
c8bb1e8f
...
...
@@ -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
==================
...
...
notifintime/backends/email.py
View file @
c8bb1e8f
...
...
@@ -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
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment