Added mailer

This commit is contained in:
glic3 2015-05-04 22:26:01 +02:00
parent f3ec1af691
commit dbe165c068
3 changed files with 2 additions and 7 deletions

View File

@ -311,11 +311,8 @@ Replace celery by a custom solution?
*priority: custom Thread backend
*bulk: wrapper arround django-mailer to avoid loading django system
pip3 install https://github.com/APSL/django-mailer-2/archive/master.zip
# TASKS_ENABLE_UWSGI_CRON_BEAT (default) for production + system check --deploy
if 'wsgi' in sys.argv and settings.TASKS_ENABLE_UWSGI_CRON_BEAT:
import uwsgi
@ -326,8 +323,6 @@ pip3 install https://github.com/APSL/django-mailer-2/archive/master.zip
# TASK_BEAT_BACKEND = ('cron', 'celerybeat', 'uwsgi')
# SHip orchestra production-ready (no DEBUG etc)
# import module and sed
# if setting.value == default. remove
# reload generic admin view ?redirect=http...

View File

@ -12,6 +12,7 @@ class EmailBackend(BaseEmailBackend):
if not email_messages:
return
num_sent = 0
# TODO if multiple messages queue, else async?
for message in email_messages:
priority = message.extra_headers.get('X-Mail-Priority', Message.NORMAL)
if priority == Message.CRITICAL:

View File

@ -12,7 +12,7 @@ def send_message(message, num, connection, bulk):
connection.close()
connection = None
if connection is None:
# Reset connection
# Reset connection with django
connection = get_connection(backend='django.core.mail.backends.smtp.EmailBackend')
connection.open()
error = None
@ -44,7 +44,6 @@ def send_pending(bulk=100):
for retries, seconds in enumerate(settings.MAILER_DEFERE_SECONDS):
delta = timedelta(seconds=seconds)
qs = qs | Q(retries=retries, last_retry__lte=now-delta)
for message in Message.objects.filter(state=Message.DEFERRED).filter(qs).order_by('priority'):
send_message(message, num, connection, bulk)
if connection is not None: