summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askbot/utils/mail.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/askbot/utils/mail.py b/askbot/utils/mail.py
index 9dc32d16..dee7f74b 100644
--- a/askbot/utils/mail.py
+++ b/askbot/utils/mail.py
@@ -1,3 +1,8 @@
+"""functions that send email in askbot
+these automatically catch email-related exceptions
+"""
+import smtplib
+import logging
from django.core import mail
from django.conf import settings as django_settings
from askbot.conf import settings as askbot_settings
@@ -39,12 +44,15 @@ def send_mail(
msg.send()
if related_object is not None:
assert(activity_type is not None)
- except Exception, e:
- logging.critical(unicode(e))
+ except Exception, error:
+ logging.critical(unicode(error))
if raise_on_failure == True:
- raise exceptions.EmailNotSent(unicode(e))
+ raise exceptions.EmailNotSent(unicode(error))
-def mail_moderators(subject_line, body_text):
+def mail_moderators(
+ subject_line = '',
+ body_text = '',
+ raise_on_failure = False):
"""sends email to forum moderators and admins
"""
from django.db.models import Q
@@ -60,7 +68,7 @@ def mail_moderators(subject_line, body_text):
try:
mail.send_mail(subject_line, body_text, from_email, recipient_list)
- except smtplib.SMPTException, e:
- logging.critical(unicode(e))
+ except smtplib.SMTPException, error:
+ logging.critical(unicode(error))
if raise_on_failure == True:
- raise exceptions.EmailNotSent(unicode(e))
+ raise exceptions.EmailNotSent(unicode(error))