Add dist files
This commit is contained in:
3
queued_mailer/__init__.py
Normal file
3
queued_mailer/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
21
queued_mailer/backend.py
Normal file
21
queued_mailer/backend.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
from django.utils.module_loading import import_string
|
||||
|
||||
from . import logger
|
||||
from .settings import EMAIL_SEND_TASK
|
||||
|
||||
|
||||
class EmailBackend(BaseEmailBackend):
|
||||
task = None
|
||||
|
||||
def __init__(self, fail_silently=False, **kwargs):
|
||||
super(EmailBackend, self).__init__(fail_silently, **kwargs)
|
||||
self.task = import_string(EMAIL_SEND_TASK)
|
||||
|
||||
def send_messages(self, email_messages):
|
||||
num_sent = 0
|
||||
for email in email_messages:
|
||||
logger.info(email)
|
||||
logger.info(self.task)
|
||||
num_sent += 1
|
||||
return num_sent
|
||||
13
queued_mailer/settings.py
Normal file
13
queued_mailer/settings.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django.conf import settings
|
||||
|
||||
EMAIL_BACKEND = getattr(
|
||||
settings,
|
||||
"QMAILER_EMAIL_BACKEND",
|
||||
"django.core.mail.backends.smtp.EmailBackend"
|
||||
)
|
||||
|
||||
EMAIL_SEND_TASK = getattr(
|
||||
settings,
|
||||
"QMAILER_SEND_TASK",
|
||||
"queued_mailer.tasks.send_message"
|
||||
)
|
||||
7
queued_mailer/tasks.py
Normal file
7
queued_mailer/tasks.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from . import logger
|
||||
from .settings import EMAIL_BACKEND
|
||||
|
||||
|
||||
def send_message():
|
||||
logger.info(EMAIL_BACKEND)
|
||||
logger.info('sent')
|
||||
Reference in New Issue
Block a user