Skip to content

Instantly share code, notes, and snippets.

@danielroseman
Created January 17, 2011 12:34
Show Gist options
  • Save danielroseman/782801 to your computer and use it in GitHub Desktop.
Save danielroseman/782801 to your computer and use it in GitHub Desktop.
Queue email backend for Django
from django.core.mail.backends.base import BaseEmailBackend
from utils.publish import publish_to_queue
class QueueBackend(BaseEmailBackend):
def send_messages(self, email_messages):
for i, email in enumerate(email_messages):
msg = email.__dict__
msg.pop('connection', None)
publish_to_queue(msg, 'mail.send')
return i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment