Add dist files
This commit is contained in:
parent
86ed9d00d7
commit
188f0a1675
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')
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
django>=1.11
|
||||||
|
celery>=4.1.1
|
24
setup.py
Normal file
24
setup.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from distutils.core import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='django-queued-mailer',
|
||||||
|
packages=['queued_mailer'],
|
||||||
|
version='0.0.1',
|
||||||
|
description='Django mail backend uses celery as email message queue',
|
||||||
|
author='jar3b',
|
||||||
|
author_email='hellotan@live.ru',
|
||||||
|
license="MIT license",
|
||||||
|
url='https://github.com/jar3b/django-queued-mailer',
|
||||||
|
keywords='python2 django email celery',
|
||||||
|
|
||||||
|
requires=['django (>= 1.11)', 'celery (>= 4.1.1)'],
|
||||||
|
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 3 - Alpha',
|
||||||
|
'Framework :: Django',
|
||||||
|
'License :: OSI Approved :: MIT License',
|
||||||
|
'Programming Language :: Python',
|
||||||
|
'Programming Language :: Python :: 2',
|
||||||
|
'Programming Language :: Python :: 2.7',
|
||||||
|
],
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user