Source

django-celery-email / djcelery_email / backends.py

Paul McLanahan b30b931 


Paul McLanahan 216d3c5 
Paul McLanahan b30b931 


ftyurin 00e8227 


Paul McLanahan 58f9586 
Yehonatan Daniv 038e73f 
Paul McLanahan 58f9586 
Paul McLanahan 92b4371 
Paul McLanahan b30b931 
Yehonatan Daniv 038e73f 
Paul McLanahan 58f9586 
from django.conf import settings
from django.core.mail.backends.base import BaseEmailBackend

from djcelery_email.tasks import send_email


class CeleryEmailBackend(BaseEmailBackend):
    def __init__(self, fail_silently=False, **kwargs):
        super(CeleryEmailBackend, self).__init__(fail_silently)
        self.init_kwargs = kwargs

    def send_messages(self, email_messages, **kwargs):
        results = []
        kwargs['_backend_init_kwargs'] = self.init_kwargs
        for msg in email_messages:
            results.append(send_email.delay(msg, **kwargs))
        return results