diff gpp/core/functions.py @ 418:20af29454e83

Fixing #202. Guard against an empty email recipient list to prevent mail errors. We log a warning if this happens.
author Brian Neal <bgneal@gmail.com>
date Sat, 16 Apr 2011 21:39:23 +0000
parents 767cedc7d12a
children 9e7ae8462f3f
line wrap: on
line diff
--- a/gpp/core/functions.py	Sat Apr 16 19:30:29 2011 +0000
+++ b/gpp/core/functions.py	Sat Apr 16 21:39:23 2011 +0000
@@ -17,6 +17,10 @@
     Use this function to send email from the site. It will obey debug settings and
     log all emails. The expedite flag, when True, will bypass the mail queue.
     """
+    recipient_list = [dest for dest in recipient_list if dest]
+    if not recipient_list:
+        logging.warning("Empty recipient_list in send_mail")
+        return
 
     if settings.MAILER_ENQUEUE_MAIL and not expedite:
         mailer.enqueue_mail(subject, message, from_email, recipient_list)