Package: django-mail-queue
Django Mail QueueThis is a fork ofhttp://github.com/dstegelman/django-mail-queuemaintained byPrivex Inc.Derek passed on ownership of the originaldjango-mail-queuePyPi package to Privex on 17 Sep 2019Privex publishes the fork under the original PyPi packagedjango-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, considergrabbing 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.Installdjango-mail-queuemaintains high compatibility, from as old as Django 1.8 on Python 2.7, up to Django 2.2 on
Python 3.7To check the compatibility, seeTravis CI, which runs the unit
tests on a variety of Python and Django versions.Download and install from PyPi using pip (recommended)pip3installdjango-mail-queue(Alternative) Manual install from GitOption 1 - Use pip to install straight from Githubpip3installgit+https://github.com/Privex/django-mail-queueOption 2 - Clone and install manually# Clone the repository from Githubgitclonehttps://github.com/Privex/django-mail-queuecddjango-mail-queue# RECOMMENDED MANUAL INSTALL METHOD# Use pip to install the source codepip3install.# ALTERNATIVE MANUAL INSTALL METHOD# If you don't have pip, or have issues with installing using it, then you can use setuptools instead.python3setup.pyinstallQuickstartBasic configurationFirst 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 TrueMAILQUEUE_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 runMAILQUEUE_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=FalseMAILQUEUE_ATTACHMENT_DIR='mailqueue-attachments'Running the migrationsOnce you've added mailqueue to yourINSTALLED_APPSplus the basic config in settings.py, run the
migrations to create the tables needed:pythonmanage.pymigrateBasic usage of the queue programmaticallySimply save an email to the database usingMailerMessage, and the queue will pick it up on it's next run.frommailqueue.modelsimportMailerMessagemy_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=contentmsg.html_content=contentmsg.save()Triggering the queue runnerTo send emails in the queue (without Celery), use the management command:# Send up to MAILQUEUE_LIMIT emails nowpythonmanage.pysend_queued_messages# You can use --limit / -l to override the settings.py limit for a specific runpythonmanage.pysend_queued_messages--limit10pythonmanage.pysend_queued_messages-l10If not using Celery, simply add a cron to your system to runmanage.py send_queued_messagesevery minute (or however
often you want).Documentationhttp://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.Support/Help/Spam/Hate MailIf you have questions/problems/suggestions the quickest way to reach me to is simply add a GitHub issue to this project.Running the Tests Locallypip install django
pip install -r requirements.txt

py.test mailqueue