aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/emails.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-05-20 07:44:28 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-05-20 07:44:28 +0200
commit2207a7db83e85abf1d4cfe88a1c340e1332533f3 (patch)
tree072fc90337315f34716bdd237347a19412c74cd5 /pyaggr3g470r/emails.py
parentImproved email notifications. (diff)
downloadnewspipe-2207a7db83e85abf1d4cfe88a1c340e1332533f3.tar.gz
newspipe-2207a7db83e85abf1d4cfe88a1c340e1332533f3.tar.bz2
newspipe-2207a7db83e85abf1d4cfe88a1c340e1332533f3.zip
Send notification messages to platform users.
Diffstat (limited to 'pyaggr3g470r/emails.py')
-rw-r--r--pyaggr3g470r/emails.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/pyaggr3g470r/emails.py b/pyaggr3g470r/emails.py
index d11fd16e..5b80fce0 100644
--- a/pyaggr3g470r/emails.py
+++ b/pyaggr3g470r/emails.py
@@ -65,7 +65,7 @@ def send_email(mfrom, mto, feed, article):
#
# Notifications
#
-def send_heroku(user, subject, plaintext):
+def send_heroku(user=None, bcc="", subject="", plaintext=""):
"""
Send an email on Heroku via Postmark.
"""
@@ -73,8 +73,11 @@ def send_heroku(user, subject, plaintext):
message = PMMail(api_key = conf.POSTMARK_API_KEY,
subject = subject,
sender = conf.ADMIN_EMAIL,
- to = user.email,
text_body = plaintext)
+ if bcc != "" and None == user:
+ message.bcc = bcc
+ elif bcc == "" and None != user:
+ message.to = user.email
message.send()
except Exception as e:
pyaggr3g470r_log.error(str(e))
@@ -90,7 +93,7 @@ def information_message(subject, plaintext):
if conf.ON_HEROKU:
# Postmark has a limit of twenty recipients per message in total.
for i in xrange(0, len(emails), 20):
- send_heroku(", ".join(emails[i:i+20]), subject, plaintext)
+ send_heroku(bcc=", ".join(emails[i:i+20]), subject=subject, plaintext=plaintext)
else:
pass
@@ -101,7 +104,7 @@ def new_account_notification(user):
plaintext = """Hello,\n\nYour account has been created. Click on the following link to confirm it:\n%s\n\nSee you,""" % \
(conf.PLATFORM_URL + 'confirm_account/' + user.activation_key)
if conf.ON_HEROKU:
- send_heroku(user, "[pyAggr3g470r] Account creation", plaintext)
+ send_heroku(user=user, subject="[pyAggr3g470r] Account creation", plaintext=plaintext)
else:
pass
@@ -112,7 +115,7 @@ def new_account_activation(user):
plaintext = """Hello,\n\nYour account has been activated. You can now connect to the platform:\n%s\n\nSee you,""" % \
(conf.PLATFORM_URL)
if conf.ON_HEROKU:
- send_heroku(user, "[pyAggr3g470r] Account activated", plaintext)
+ send_heroku(user=user, subject="[pyAggr3g470r] Account activated", plaintext=plaintext)
else:
pass
bgstack15