Skip to main content

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

This fork reinstates the retry logic that stops retrying after Task.max_retries attempts, where the default is 3.

Using django-celery-email

To enable django-celery-email 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.

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',
    ...
}

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. See the Celery docs for more info.

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

Changelog

1.0.3 - 2012.03.06

  • Backend will now pass any kwargs with which it is initialized to the email sending backend.

  • Thanks to Fedor Tyurin for the contribution.

1.0.2 - 2012.02.21

  • Task and backend now accept kwargs that can be used in signal handlers.

  • Task now returns the result from the email sending backend.

  • Thanks to Yehonatan Daniv for these changes.

1.0.1 - 2011.10.06

  • Fixed a bug that resulted in tasks that were throwing errors reporting success.

  • If there is an exception thrown by the sending email backend, the result of the task will now be this exception.

Metadata

Release files for django-celery-email-with-retry 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-celery-email-with-retry 1.0.3
File Size Uploaded Provenance Actions
django-celery-email-with-retry-1.0.3.tar.gz 7.3 kB Without provenance Details for django-celery-email-with-retry-1.0.3.tar.gz

Release files / django-celery-email-with-retry-1.0.3.tar.gz

Download URL django-celery-email-with-retry-1.0.3.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c925cad3263d80442567335d4969384bbe4195da66b6f15ce205abdb2b3bf540
BLAKE2b-256 checksum
How to use checksums
1cb04e92dbc8a02d809af2c6988d392ca18e3e56804b46d73a503fb50039fb0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-celery-email-with-retry 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page