Django Mail Queue Documentation



Similar documents
Fritz Speed Documentation

django-helpdesk Documentation

plonesocial.auth.rpx Documentation

monoseq Documentation

django-gcm Documentation

Healthstone Monitoring System

django-cron Documentation

Django FTP Deploy Documentation

SagePay payment gateway package for django-oscar Documentation

HP WBEM Services Software Developer's Kit Version A Release Notes. HP-UX 11i v3

Django Two-Factor Authentication Documentation

Integrate Rails into an Existing IIS Web infrastructure using Mongrel

8.7. Resource Kit User Guide

Open Source Used In Cisco Instant Connect for ios Devices 4.9(1)

Allscripts Professional EHR

Google Cloud Print User's Manual

latest Release 0.2.6

Google Cloud Print Setup. User s Guide

Symantec Enterprise Vault

Symantec Enterprise Vault

Memopol Documentation

Flask-SSO Documentation

Django FTP server Documentation

S3 Monitor Design and Implementation Plans

Subversion Server for Windows

Magento OpenERP Integration Documentation

Open Source Software used in the product

Configuring Mozilla Thunderbird to Access Your SAS Account

Rapid Website Deployment With Django, Heroku & New Relic

EPESI PARTNERSHIP PROGRAM [EPP]

Analog Documentation. Release Fabian Büchler

Version Control with Subversion

Django on AppEngine Documentation

BlackBerry Web Desktop Manager. Version: 5.0 Service Pack: 4. User Guide

System Center Virtual Machine Manager 2012 R2 Plug-In. Feature Description

4.0. Offline Folder Wizard. User Guide

Made Easy Windows Sync App Tutorial

Hyper V Windows 2012 and 8. Virtual LoadMaster for Microsoft Hyper V on Windows Server 2012, 2012 R2 and Windows 8. Installation Guide

Symantec Enterprise Vault

Azure Multi-Factor Authentication. KEMP LoadMaster and Azure Multi- Factor Authentication. Technical Note

ONE-TOUCH MAIL V 2.3 MANUAL

MultiValue Dashboard. Installation Guide

Symantec Enterprise Vault

User Guide for the Polycom SoundStation IP 6000 Phone

Auto Print User s Manual

8.10. Required Ports

Log Insight Manager. Deployment Guide

Enterprise Vault.cloud. Microsoft Exchange Managed Folder Archiving Guide

RSA Two Factor Authentication

Quick Reference. Administrator Guide

Port Following. Port Following. Feature Description

Sage HRMS 2014 Sage Employee Self Service Tech Installation Guide for Windows 2003, 2008, and October 2013

OpenDJ LDAP SDK Release Notes

GEO Sticky DNS. GEO Sticky DNS. Feature Description

Symantec Enterprise Vault

Spam Manager. Quarantine Administrator Guide

DjNRO Release 0.9 July 14, 2015

PCRecruiter Internal Client

Business Portal for Microsoft Dynamics GP. Electronic Document Delivery Release 10.0

Nupic Web Application development

[MD5 Message Digests] derived from the RSA Data Security, Inc. MD5 Message Digest Algorithm

to Fax Quick Start Tutorial MM D

Sophos for Microsoft SharePoint Help. Product version: 2.0

Open Source Used In Cisco IronPort Encryption SDK

Simba ODBC Driver with SQL Connector for Apache Cassandra

Boost Libraries Boost Software License Version 1.0

Good Share Client User Guide for ios Devices

TIBCO Slingshot User Guide

Policy Based Encryption Z. Administrator Guide

BMC Remedy Action Request System 7.0 Open Source License Agreements

Symantec Enterprise Vault

Purchase Order Management Magento Module By:

RSA Two Factor Authentication. Feature Description

ConvincingMail.com Marketing Solution Manual. Contents

Altiris Monitor Pack for Servers 7.1 SP2 from Symantec Release Notes

Software Package Document exchange (SPDX ) Tools. Version 1.2. Copyright The Linux Foundation. All other rights are expressly reserved.

Aras Innovator Internet Explorer Client Configuration

[The BSD License] Copyright (c) Jaroslaw Kowalski

CORPORATE HEADQUARTERS Elitecore Technologies Ltd. 904 Silicon Tower, Off. C.G. Road, Ahmedabad , INDIA

Virtual LoadMaster for Microsoft Hyper-V

ADS Integration Guide

CYBEROAM WINDOWS DOMAIN CONTROLLER INTEGRATION GUIDE VERSION:

Installation and Testing of NMM (Windows)

JobScheduler Web Services Executing JobScheduler commands

Radius Integration Guide Version 9

Z Documentation. Release 2. Bart Thate

Exchange 2003 Standard Journaling Guide

CA Service Desk Manager - Mobile Enabler 2.0

Python DNS Failover Documentation

DEPLOYING EMC DOCUMENTUM BUSINESS ACTIVITY MONITOR SERVER ON IBM WEBSPHERE APPLICATION SERVER CLUSTER

What s New in LANDESK Service Desk Version 7.8. Abstract

Domains Help Documentation This document was auto-created from web content and is subject to change at any time. Copyright (c) 2016 SmarterTools Inc.

Aras Innovator.NET Client Security Policy Configuration

Transcription:

Django Mail Queue Documentation Release 2.3.0 Derek Stegelman May 21, 2016

Contents 1 Quick Start Guide 3 1.1 Requirements............................................... 3 1.2 Installation................................................ 3 1.3 Setup................................................... 3 1.4 Synchronously.............................................. 4 1.5 Celery.................................................. 4 1.6 Management Command/URL...................................... 4 1.7 Misc Settings............................................... 4 2 Usage 5 2.1 To Send an Email............................................. 5 2.2 Attaching Files.............................................. 5 2.3 Adding a Reply To header........................................ 6 2.4 Sending to Multiple Recipients..................................... 6 2.5 Using the Management Command.................................... 6 3 Management Commands 7 3.1 Send Queued messages.......................................... 7 3.2 Clear Sent messages........................................... 7 4 License 9 5 Contributing 11 6 Indices and tables 13 i

ii

Django Mail Queue Documentation, Release 2.3.0 Mail Queue is a new way to send and keep track of email in your Django application. Mail queue stores each email you send and records success/failure. You can requeue up un-sent mail and review the mail generated by your app. Contents: Contents 1

Django Mail Queue Documentation, Release 2.3.0 2 Contents

CHAPTER 1 Quick Start Guide As of 2.0 Django Mail Queue is now Python 3 compatible! 1.1 Requirements Django Mail Queue requires: python 2.7 or greater django 1.8 or greater Django Mail Queue is tested against Python 2.7, 3.x and Django 1.8 and 1.9. If using Celery, you ll need celery 3 or greater. 1.2 Installation Using pip: pip install django-mail-queue Go to https://github.com/dstegelman/django-mail-queue if you need to download a package or clone the repo. 1.3 Setup Open settings.py and add mailqueue to your INSTALLED_APPS: INSTALLED_APPS = ( 'mailqueue', ) Mailqueue can be configured a few different ways: Configured to send mail synchronously in the web request. Configured to send mail asynchronously through Celery. Configured to queue up and send mail in bulk through a management command. Confgiured to queue up and send mail in bulk through a hitting a URL. (pending deprecation) 3

Django Mail Queue Documentation, Release 2.3.0 1.4 Synchronously This is the default setting for mailqueue. You do not need to set any additional settings for this option. 1.5 Celery Celery is disabled by default, you can turn it on the use of Celery and send emails in real time using MAILQUEUE_CELERY in settings: MAILQUEUE_CELERY = True Instead of using the cron job the celery task worker will attempt to send email when it s saved. The cron job will clean up any emails that get lost. 1.6 Management Command/URL First, in order to queue up the mail and not send on save(), you ll need to set the queue up: MAILQUEUE_QUEUE_UP = True A cron job can be set up to work one of two ways: using a management command or an HTTP request. Both methods run the mail queue which grabs emails and sends them. To decrease load, it only tries to send 30 emails at a time. This number can be changed by using MAILQUEUE_LIMIT in settings: MAILQUEUE_LIMIT = 50 Using the management command: python manage.py send_queued_messages You can also override MAILQUEUE_LIMIT by using the --limit or -l option: python manage.py send_queued_messages --limit=10 HTTP request: urlpatterns = patterns('', (r'^mail-queue/', include('mailqueue.urls')), ) If you re running cron from another machine or can t run python directly, you can add the above to urls.py and use a utility like curl to hit /mail-queue/. 1.7 Misc Settings You can force mail queue to use default file system storage with MEDIA_ROOT as the storage folder. You may want to do this because by default mail queue will use your default file storage, and attachments are known to not work against various storages such as S3 Boto. To force Django s File System storage: MAILQUEUE_STORAGE = True 4 Chapter 1. Quick Start Guide

CHAPTER 2 Usage 2.1 To Send an Email Create a new MailerMessage() object: from mailqueue.models import MailerMessage new_message = MailerMessage() new_message.subject = "My Subject" new_message.to_address = "someone@example.com" new_message.bcc_address = "myblindcarboncopy@yo.com" new_message.from_address = "hello@example.com" new_message.content = "Mail content" new_message.html_content = "<h1>mail Content</h1>" new_message.app = "Name of your App that is sending the email." new_message.save() When save is called, Django will immediately try to send the email. Should it fail, it will be marked as unsent, and wait for the next time the job is called. Of course, the BCC address is optional, as well as html content. 2.2 Attaching Files File attachments can be added to the e-mail with MailerMessage s add_attachment method: from mailqueue.models import MailerMessage from django.core.files import File message = MailerMessage(to_address="foo@mail.com", from_address="bar@mail.com") photo_one = File(open("Poznan_square.jpg", "r")) message.add_attachment(photo_one) #...you can add more than one file attachment photo_two = File(open("Poznan_Malta-lake.jpg", "r")) message.add_attachment(photo_two) message.save() 5

Django Mail Queue Documentation, Release 2.3.0 2.3 Adding a Reply To header You can add a reply to header to your emails be setting: from mailqueue.models import MailerMessage new_message = MailerMessage() new_message.reply_to = 'reply@myawesomeaddress.com' 2.4 Sending to Multiple Recipients To include more than one BCC in your email, just separate the addresses with a comma: message.bcc_address = "one@mail.com, two@mail.com, three@mail.com" As of version 2.2.0 multiple recipients may be included in the to_address field as well: message.bcc_address = "one@mail.com, two@mail.com, three@mail.com" 2.5 Using the Management Command You can use the management command to send email: python manage.py send_queued_messages --limit=20 6 Chapter 2. Usage

CHAPTER 3 Management Commands 3.1 Send Queued messages You can use this management command to send email if you do not setup a cron job or use celery. You can specify a limit on the amount of emails you want to attempt to send at one time.: python manage.py send_queued_messages --limit=20 3.2 Clear Sent messages You can use a management command to clear out successfully sent emails from the database:./manage.py clear_sent_messages 7

Django Mail Queue Documentation, Release 2.3.0 8 Chapter 3. Management Commands

CHAPTER 4 License Copyright (c) 2011-2016 Derek Stegelman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software ), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PAR- TICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT- WARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9

Django Mail Queue Documentation, Release 2.3.0 10 Chapter 4. License

CHAPTER 5 Contributing Mail Queue is hosted on github at https://github.com/dstegelman/django-mail-queue Contributions are more than welcome! 11

Django Mail Queue Documentation, Release 2.3.0 12 Chapter 5. Contributing

CHAPTER 6 Indices and tables genindex modindex search 13