from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.mail.backends.base import BaseEmailBackend class DjrillBackend(BaseEmailBackend): """ Mandrill API Email Backend """ def __init__(self, fail_silently=False, **kwargs): """ Set the API key, API url and set the action url. """ super(DjrillBackend, self).__init__(**kwargs) self.api_key = getattr(settings, "MANDRILL_API_KEY", None) self.api_url = getattr(settings, "MANDRILL_API_URL", None) if not self.api_key: raise ImproperlyConfigured("You have not set your mandrill api key " "in the settings.py file.") if not self.api_url: raise ImproperlyConfigured("You have not added the Mandrill api " "url to your settings.py") self.api_action = self.api_url + "/messages/send.json" def open(self): """ Ping the Mandrill API to make sure they are up and that we have a valid API key and sender. """ pass def send_messages(self, email_messages): pass