Django mail backend uses celery as email message queue
Django >= 1.11, Celery >= 4.1.1
- Add
git+https://github.com/jar3b/django-queued-mailer.git
to requirements.txt - Install package
pip install --upgrade git+https://github.com/jar3b/django-queued-mailer.git
- Modify Django settings: set proper email backend
EMAIL_BACKEND = 'queued_mailer.backend.EmailBackend'
- Run celery worker
celery -A project worker
- setup Celery routes
app.conf.task_queues = (
Queue('default', Exchange('default'), routing_key='default'),
Queue('qmailer_mail_queue', routing_key='qmailer.send.#'),
)
- start separate worker
celery -A project worker -Q qmailer_mail_queue --concurrency=1
Django settings:
QMAILER_EMAIL_BACKEND
- set email backend, defaultdjango.core.mail.backends.smtp.EmailBackend
QMAILER_TASK_QUEUE_NAME
- queue name for routing, defaultdefault
, if you use separate "serial" worker as described above, you need to specify this option