Skip to main content

Build Status PyPi Version License Button PyPI - Downloads PyPI - Python Version GitHub last commit

Django Mail Queue

This is a fork of http://github.com/dstegelman/django-mail-queue maintained by Privex Inc.

Derek passed on ownership of the original django-mail-queue PyPi package to Privex on 17 Sep 2019

Privex publishes the fork under the original PyPi package django-mail-queue (since v3.2.0).

This fork is considered to be actively maintained by Privex for both bug fixes and feature additions since December 2018.

If our fork has helped you, consider grabbing a VPS or Dedicated Server from Privex - prices start at as little as US$0.99/mo (yes that's 99 cents a month, and we take cryptocurrency!)

Mail Queue provides an easy and simple way to send email. Each email is saved and queued up either in real time or with Celery. As always, feedback, bugs, and suggestions are welcome.

Install

django-mail-queue maintains high compatibility, from as old as Django 1.8 on Python 2.7, up to Django 2.2 on Python 3.7

To check the compatibility, see Travis CI, which runs the unit tests on a variety of Python and Django versions.

Download and install from PyPi using pip (recommended)

pip3 install django-mail-queue

(Alternative) Manual install from Git

Option 1 - Use pip to install straight from Github

pip3 install git+https://github.com/Privex/django-mail-queue

Option 2 - Clone and install manually

# Clone the repository from Github
git clone https://github.com/Privex/django-mail-queue
cd django-mail-queue

# RECOMMENDED MANUAL INSTALL METHOD
# Use pip to install the source code
pip3 install .

# ALTERNATIVE MANUAL INSTALL METHOD
# If you don't have pip, or have issues with installing using it, then you can use setuptools instead.
python3 setup.py install

Quickstart

Basic configuration

First install the package into your project (see above).

Open settings.py and add mailqueue to your INSTALLED_APPS:

INSTALLED_APPS = (
    'mailqueue',
)

Add the below settings, and adjust as needed:

# If you're using Celery, set this to True
MAILQUEUE_CELERY = False

# Enable the mail queue. If this is set to False, the mail queue will be disabled and emails will be 
# sent immediately instead.
MAILQUEUE_QUEUE_UP = True

# Maximum amount of emails to send during each queue run
MAILQUEUE_LIMIT = 50

# If MAILQUEUE_STORAGE is set to True, will ignore your default storage settings
# and use Django's filesystem storage instead (stores them in MAILQUEUE_ATTACHMENT_DIR) 
MAILQUEUE_STORAGE = False
MAILQUEUE_ATTACHMENT_DIR = 'mailqueue-attachments'

Running the migrations

Once you've added mailqueue to your INSTALLED_APPS plus the basic config in settings.py, run the migrations to create the tables needed:

python manage.py migrate

Basic usage of the queue programmatically

Simply save an email to the database using MailerMessage, and the queue will pick it up on it's next run.

from mailqueue.models import MailerMessage

my_email = "dave@example.com"
my_name = "Dave Johnston"
content = """
Dear John,

This is an example email from Dave.

Thanks,
Dave Johnston!
"""

msg = MailerMessage()
msg.subject = "Hello World"
msg.to_address = "john@example.com"

# For sender names to be displayed correctly on mail clients, simply put your name first
# and the actual email in angle brackets 
# The below example results in "Dave Johnston <dave@example.com>"
msg.from_address = '{} <{}>'.format(my_name, my_email)

# As this is only an example, we place the text content in both the plaintext version (content) 
# and HTML version (html_content).
msg.content = content
msg.html_content = content
msg.save()

Triggering the queue runner

To send emails in the queue (without Celery), use the management command:

# Send up to MAILQUEUE_LIMIT emails now
python manage.py send_queued_messages

# You can use --limit / -l to override the settings.py limit for a specific run
python manage.py send_queued_messages --limit 10
python manage.py send_queued_messages -l 10

If not using Celery, simply add a cron to your system to run manage.py send_queued_messages every minute (or however often you want).

Documentation

http://readthedocs.org/docs/django-mail-queue/en/latest/

Mail Queue provides an admin interface to view all attempted emails and actions for resending failed messages.

Screenshot of Email List

Screenshot of Email Actions

Support/Help/Spam/Hate Mail

If you have questions/problems/suggestions the quickest way to reach me to is simply add a GitHub issue to this project.

Running the Tests Locally

pip install django
pip install -r requirements.txt

py.test mailqueue

Metadata

Release files for django-mail-queue 3.2.6

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-mail-queue 3.2.6
File Size Uploaded
django-mail-queue-3.2.6.tar.gz 12.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-mail-queue 3.2.6
File Interpreter ABI Platform
django_mail_queue-3.2.6-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 32.4 kB

Release files / django-mail-queue-3.2.6.tar.gz

Download URL django-mail-queue-3.2.6.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dae6d3baeba3dcdb3d38709cb50cae91f90d0642a627ed9e32f4f90a426f387e
BLAKE2b-256 checksum
How to use checksums
268ecd0a860b4f91b0f0b41638e68fb3812978e55f2a6e534631d92fc91f701c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.14

Release files / django_mail_queue-3.2.6-py2.py3-none-any.whl

Download URL django_mail_queue-3.2.6-py2.py3-none-any.whl
Size 19.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
258f5f68efbea9aefef85f241dc27e0bd17543903331866c33a7fd1b66ff7f7f
BLAKE2b-256 checksum
How to use checksums
0032006919b278e108f90e389faaacfa3384eff0fd3361575bf714c875445ca4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.14

Release history Release notifications | RSS feed

This release

3.2.6 This release

2 release files

3.2.5

1 release file

3.2.4

1 release file

3.2.3

1 release file

3.2.2

2 release files

3.2.1

2 release files

3.1.6

2 release files

3.1.5

2 release files

3.1.4

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.2

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.6.4

1 release file

1.6.3

1 release file

1.6.2

1 release file

1.6.1

1 release file

1.6

1 release file

1.5.3

1 release file

1.5.2

1 release file

1.5.1

1 release file

1.5.0

1 release file

1.4.0

1 release file

1.3.1

1 release file

1.3.0

1 release file

1.2.4

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.1.0

1 release file

1.0.1

1 release file

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