Commits

Waldemar Kornewald committed 578f17e Merge

merged with mailfix branch

Comments (0)

Files changed (2)

 from django.core.mail import EmailMultiAlternatives
 from django.core.exceptions import ImproperlyConfigured
 from google.appengine.api import mail as aeemail
+from google.appengine.runtime import apiproxy_errors
 
-def _send_deferred(message):
-    message.send()
+def _send_deferred(message, fail_silently=False):
+    try:
+        message.send()
+    except (aeemail.Error, apiproxy_errors.Error):
+        if not fail_silently:
+            raise
 
 class EmailBackend(BaseEmailBackend):
     can_defer = False
             return True
         try:
             message.send()
-        except aeemail.Error:
+        except (aeemail.Error, apiproxy_errors.Error):
             if not self.fail_silently:
                 raise
             return False
 
     def _defer_message(self, message):
         from google.appengine.ext import deferred
-        deferred.defer(_send_deferred, message)
+        from django.conf import settings
+        queue_name = getattr(settings, 'EMAIL_QUEUE_NAME', 'default')
+        deferred.defer(_send_deferred, 
+                       message, 
+                       fail_silently=self.fail_silently,
+                       _queue=queue_name)
 
 class AsyncEmailBackend(EmailBackend):
     can_defer = True
 else:
     EMAIL_BACKEND = 'djangoappengine.mail.EmailBackend'
 
+# Specify a queue name for the async. email backend
+EMAIL_QUEUE_NAME = 'default'
+
 PREPARE_UPLOAD_BACKEND = 'djangoappengine.storage.prepare_upload'
 SERVE_FILE_BACKEND = 'djangoappengine.storage.serve_file'
 DEFAULT_FILE_STORAGE = 'djangoappengine.storage.BlobstoreStorage'