A Django email backend that uses a celery task for sending the email.

Overview

django-celery-email - A Celery-backed Django Email Backend

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

Warning

This version requires the following versions:

  • Python >= 3.5
  • Django 2.2, and 3.0
  • Celery 4.0

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.

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.", '[email protected]', ['[email protected]']),
    ('Dammit Walter', "Let's go bowlin'.", '[email protected]', ['[email protected]']),
)
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.

Changelog

3.0.0 - 2019.12.10

  • Support for Django 3.0
  • Support for Python 3.8
  • Droppped support for Django 1.x, Django 2.0 and Django 2.1
  • Droppped support for Python 2.7

2.0.2 - 2019.05.29

  • Reduce memory usage by running email_to_dict on chunks. Thanks Paul Brown.
  • Simplify dict_to_email for readability and efficiency. Thanks Paul Brown.
  • Update test matrix for supported versions of Django, Celery and Python. Thanks James.

2.0.1 - 2018.18.27

  • Fix bug preventing sending text/* encoded mime attachments. Thanks Cesar Canassa.

2.0 - 2017.07.10

  • Support for Django 1.11 and Celery 4.0
  • Dropped support for Celery 2.x and 3.x
  • Dropped support for Python 3.3

1.1.5 - 2016.07.20

  • Support extra email attributes via CELERY_EMAIL_MESSAGE_EXTRA_ATTRIBUTES setting
  • Updated version requirements in README

1.1.4 - 2016.01.19

  • Support sending email with embedded images. Thanks Georg Zimmer.
  • Document CELERY_EMAIL_CHUNK_SIZE. Thanks Jonas Haag.
  • Add exception handling to email backend connection. Thanks Tom.

1.1.3 - 2015.11.06

  • Support setting celery.base from string. Thanks Matthew Jacobi.
  • Use six for py2/3 string compatibility. Thanks Matthew Jacobi.
  • Pass content_subtype back in for retries. Thanks Mark Joshua Tan.
  • Rework how tests work, add tox, rework travis-ci matrix.
  • Use six from django.utils.
  • Release a universal wheel.

1.1.2 - 2015.07.06

  • Fix for HTML-only emails. Thanks gnarvaja.

1.1.1 - 2015.03.20

  • Fix for backward compatibility of task kwarg handling - Thanks Jeremy Thurgood.

1.1.0 - 2015.03.06

  • New PyPI release rolling up 1.0.5 changes and some cleanup.
  • More backward compatability in task. Will still accept message objects and lists of message objects.
  • Thanks again to everyone who contributed to 1.0.5.

1.0.5 - 2014.08.24

  • Django 1.6 support, Travis CI testing, chunked sending & more - thanks Jonas Haag.
  • HTML email support - thanks Andres Riancho.
  • Support for JSON transit for Celery, sponsored by DigiACTive.
  • Drop support for Django 1.2.

1.0.4 - 2013.10.12

  • Add Django 1.5.2 and Python 3 support.
  • Thanks to Stefan Wehrmeyer for the contribution.

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.
Owner
Paul McLanahan
Backend Webdev @mozilla. I also go by @pmac for most of my coding tasks.
Paul McLanahan
automatic mails sender with attachments

أزعجني لين تدربني Automatic mails sender with attachments. Note: You need to have gmail account & and you need to turn on "Less secure app access" set

6 Dec 30, 2022
Using this repository you can send mails to multiple recipients.Was created in support of Ukraine, to turn society`s attention to war.

mails-in-support-of-UA Using this repository you can send mails to multiple recipients.Was created in support of Ukraine, to turn society`s attention

Oleksii Budzinskiy 2 Mar 04, 2022
Send email in Python conveniently for gmail using yagmail

yagmail -- Yet Another GMAIL/SMTP client For the asynchronous asyncio version, look here: https://github.com/kootenpv/aioyagmail The goal here is to m

Pascal van Kooten 2.4k Dec 31, 2022
An offline Phishing Email Analyzer.

An offline Phishing Email Analyzer.

Kamran Saifullah (Frog Man) 11 Oct 19, 2022
Fastapi mail system sending mails(individual, bulk) attachments(individual, bulk)

Fastapi-mail The fastapi-mail simple lightweight mail system, sending emails and attachments(individual && bulk) 🔨 Installation $ pip install fastap

Sabuhi 399 Dec 29, 2022
Dotfiles and some scripts for NeoMutt

Mutt dotfiles Robust Mutt configs with examples for the following account types: Generic IMAP/SMTP Google (Gmail/Gsuite etc) via IMAP/SMTP Microsoft O

CEUK 29 Jan 04, 2023
A light-weight, modular, message representation and mail delivery framework for Python.

Marrow Mailer A highly efficient and modular mail delivery framework for Python 2.6+ and 3.2+, formerly called TurboMail. © 2006-2019, Alice Bevan-McG

Marrow Open Source Collective 255 Dec 28, 2022
This is a bot that interacts with you over voice and sends mail.Uses speech_recognition,pyttsx3 and smtplib

AutoMail This is a bot that interacts with you over voice and sends mail Before you run the bot , go to mail.py and put your respective email address

Aditya Subrahmanya Bhat 2 Nov 04, 2022
An OSINT program that allows you to uncover a censored domain in an email adress

An OSINT program that allows you to uncover a censored domain in an email adress. Useful when you extract email from Instagram or Twitter password recovery function.

aet 3 Dec 16, 2021
Simple Email Sender using Python 3.

Email Sender 使用 Python 3 实现的简单邮件发送工具。 Version: 0.1.2 (Beta) 主要功能 使用 SMTP 协议发送邮件 支持 SSL/TLS 、 STARTTLS 加密(为保证安全,强制加密发送) 支持邮件模板与邮件生成 支持向多人群发邮件 日志记录 脚本执行

SUMSC 1 Feb 13, 2022
A Django app that allows you to send email asynchronously in Django. Supports HTML email, database backed templates and logging.

Django Post Office Django Post Office is a simple app to send and manage your emails in Django. Some awesome features are: Allows you to send email as

User Inspired 856 Dec 25, 2022
Disposable email validator for python

disposable-email-validator installation pip install disposable-email-validator

1 Jan 05, 2022
Send e-mails to teachers with specified school-website using Aula, anonymously

Information : This only works in Denmark! Send e-mails to teachers with specified school-website using Aula, anonymously. Find your school via the att

Binary.club 1 Jan 24, 2022
This library is helpful when creating accounts, it has everything you need for this

AccountGeneratorHelper Library to facilitate accounts generation. Unofficial API for temp email services. Receive SMS from free services. Parsing and

Denis 52 Jan 07, 2023
A Python Mail Server

Salmon - A Python Mail Server Download: https://pypi.org/project/salmon-mail/ Source: https://github.com/moggers87/salmon Docs: https://salmon-mail.re

Matt Molyneaux 582 Dec 30, 2022
send email & telegram message whenever an analog in is recieved

send email & telegram message whenever an analog in is recieved (so when attached to an alarm siren out it will alert via mail)

Naor Livne 2 Feb 11, 2022
A simple email sender

Email-Sender Un semplice Email-Sender che utilizza il modulo smtplib con aggiunta di interfaccia grafica realizzata con il modulo tkinter Per il corre

Vincenzo Caliendo 0 Jan 14, 2022
Temp-SMS-Receive - A Program Which Allows You To Receive Temp SMS

Welcome to Temp-SMS-Receive 👋 A Program Which Allows You To Receive Temp SMS AP

Sandaru Ashen Fernando 21 Dec 10, 2022
Email-osint - Email OSINT tool written in python3

Email-osint - Email OSINT tool written in python3

Surtains 7 Nov 28, 2022
Django email backends and webhooks for Amazon SES, Mailgun, Mailjet, Postmark, SendGrid, Sendinblue, SparkPost and more

Django email backends and webhooks for Amazon SES, Mailgun, Mailjet, Postmark, SendGrid, Sendinblue, SparkPost and more

1.4k Jan 01, 2023