Skip to main content

An async Django email backend using celery (forked from django-celery-email)

Project description

https://img.shields.io/pypi/v/django-celery-email-reboot.svg

A Django email backend that uses a Celery queue for out-of-band sending of the messages.

This is a fork of django_celery_email. As this package has gone unmaintained for some time, we have decided to maintain the package in order to maintain compatibility with future Django versions, starting with Django 4.x and 5.x.

This new package is available in pypi under the name django-celery-email-reboot: https://pypi.org/project/django-celery-email-reboot/

Using django-celery-email-reboot

Install from Pypi using:

pip install django-celery-email-reboot

To enable django-celery-email-reboot for your project you need to add djcelery_email to INSTALLED_APPS:

INSTALLED_APPS += ("djcelery_email",)

You must then set django-celery-email as your EMAIL_BACKEND:

EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'

By default django-celery-email will use Django’s builtin SMTP email backend for the actual sending of the mail. If you’d like to use another backend, you may set it in CELERY_EMAIL_BACKEND just like you would normally have set EMAIL_BACKEND before you were using Celery. In fact, the normal installation procedure will most likely be to get your email working using only Django, then change EMAIL_BACKEND to CELERY_EMAIL_BACKEND, and then add the new EMAIL_BACKEND setting from above.

Mass email are sent in chunks of size CELERY_EMAIL_CHUNK_SIZE (defaults to 10).

If you need to set any of the settings (attributes) you’d normally be able to set on a Celery Task class had you written it yourself, you may specify them in a dict in the CELERY_EMAIL_TASK_CONFIG setting:

CELERY_EMAIL_TASK_CONFIG = {
    'queue' : 'email',
    'rate_limit' : '50/m',  # * CELERY_EMAIL_CHUNK_SIZE (default: 10)
    ...
}

There are some default settings. Unless you specify otherwise, the equivalent of the following settings will apply:

CELERY_EMAIL_TASK_CONFIG = {
    'name': 'djcelery_email_send',
    'ignore_result': True,
}

After this setup is complete, and you have a working Celery install, sending email will work exactly like it did before, except that the sending will be handled by your Celery workers:

from django.core import mail

emails = (
    ('Hey Man', "I'm The Dude! So that's what you call me.", 'dude@aol.com', ['mr@lebowski.com']),
    ('Dammit Walter', "Let's go bowlin'.", 'dude@aol.com', ['wsobchak@vfw.org']),
)
results = mail.send_mass_mail(emails)

results will be a list of celery AsyncResult objects that you may ignore, or use to check the status of the email delivery task, or even wait for it to complete if want. You have to enable a result backend and set ignore_result to False in CELERY_EMAIL_TASK_CONFIG if you want to use these. You should also set CELERY_EMAIL_CHUNK_SIZE = 1 in settings if you are concerned about task status and results.

See the Celery docs for more info.

len(results) will be the number of emails you attempted to send divided by CELERY_EMAIL_CHUNK_SIZE, and is in no way a reflection on the success or failure of their delivery.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_celery_email_reboot-4.1.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

django_celery_email_reboot-4.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

django_celery_email_reboot-4.1.0-py2.py3-none-any.whl (8.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django_celery_email_reboot-4.1.0.tar.gz.

File metadata

File hashes

Hashes for django_celery_email_reboot-4.1.0.tar.gz
Algorithm Hash digest
SHA256 d2a1a9d65879d370de29064a4da95cc8ce458a64b52fbd84287341454926e381
MD5 f8e10b2f9e10591e0a789eec0fd6f663
BLAKE2b-256 72dfd4d11e917ed830a443e31becdd9acc30a36e0264c2904e9f74829c047193

See more details on using hashes here.

File details

Details for the file django_celery_email_reboot-4.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_celery_email_reboot-4.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe10c8300c25b76d11b05a5463ca5489957190c171d07632847de4f15d6ad07e
MD5 a15f16ebf19ec99d449f94e4c7811eb1
BLAKE2b-256 8ee1e6017225c27e48e55dee02a911daaa5ae0fc74927f9cccadff116f182088

See more details on using hashes here.

File details

Details for the file django_celery_email_reboot-4.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_celery_email_reboot-4.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 51f8f3165f3b81725cb954dba4553ba1a3e8e8f615e41d59585d28c038d5f1b8
MD5 0a92c6a3ebbd45cc76c42c6b4a59e14f
BLAKE2b-256 00bcf496191438bd450e0039c493ac87681af067817cca82dcd1ac538ce92691

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page