diff --git a/djrill/mail/__init__.py b/djrill/mail/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/djrill/mail/backends/__init__.py b/djrill/mail/backends/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/djrill/mail/backends/djrill.py b/djrill/mail/backends/djrill.py new file mode 100644 index 0000000..be4ba9c --- /dev/null +++ b/djrill/mail/backends/djrill.py @@ -0,0 +1,36 @@ +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 diff --git a/settings/base.py b/settings/base.py index c79b5b7..11f3758 100644 --- a/settings/base.py +++ b/settings/base.py @@ -24,6 +24,9 @@ DATABASES = { MANDRILL_API_KEY = None MANDRILL_API_URL = "http://mandrillapp.com/api/1.0/" +#EMAIL BACKEND +EMAIL_BACKEND = "djrill.mail.backends.djrill.DjrillBackend" + # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name