Permalink
Browse files

Fix django email backend error handling behaviour when fail_silently=…

…False

(Thanks to matclayton for the heads-up)
  • Loading branch information...
Toby White
Toby White committed Dec 9, 2010
1 parent 57a1522 commit 452e4e32123fc186f17a5f92aaea932e86978cc4
Showing with 8 additions and 6 deletions.
  1. +2 −4 django_email_backend.py
  2. +6 −2 gmail.py
View
@@ -12,9 +12,7 @@ def __init__(self, fail_silently=False, *args, **kwargs):
def send_messages(self, messages):
n = 0
for message in messages:
- try:
- self.gmail_proxy.send_mail(message.message())
+ sent = self.gmail_proxy.send_mail(message.message())
+ if sent:
n += 1
- except MessageSendingFailure:
- pass
return n
View
@@ -65,8 +65,12 @@ def send_mail(self, msg):
data = urllib.urlencode([(k, v.encode('utf-8')) for k, v in values.items()])
status, errmsg = self.connection.make_request(data)
- if status != 204 and not self.fail_silently:
- raise MessageSendingFailure(errmsg)
+ if status != 204:
+ if not self.fail_silently:
+ raise MessageSendingFailure(errmsg)
+ else:
+ return False
+ return True
if __name__ == '__main__':

0 comments on commit 452e4e3

Please sign in to comment.