Debian Codegraph @

README.rst

raw
1 ==========================================================
2 django-celery-email - A Celery-backed Django Email Backend
3 ==========================================================
4
5 .. image:: https://img.shields.io/travis/pmclanahan/django-celery-email/master.svg
6 :target: https://travis-ci.org/pmclanahan/django-celery-email
7 .. image:: https://img.shields.io/pypi/v/django-celery-email.svg
8 :target: https://pypi.python.org/pypi/django-celery-email
9
10 A `Django`_ email backend that uses a `Celery`_ queue for out-of-band sending
11 of the messages.
12
13 .. _`Celery`: http://celeryproject.org/
14 .. _`Django`: http://www.djangoproject.org/
15
16 .. warning::
17
18 This version requires the following versions:
19
20 * Python >= 3.5
21 * Django 2.2, and 3.0
22 * Celery 4.0
23
24 Using django-celery-email
25 =========================
26
27 To enable ``django-celery-email`` for your project you need to add ``djcelery_email`` to
28 ``INSTALLED_APPS``::
29
30 INSTALLED_APPS += ("djcelery_email",)
31
32 You must then set ``django-celery-email`` as your ``EMAIL_BACKEND``::
33
34 EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'
35
36 By default ``django-celery-email`` will use Django's builtin ``SMTP`` email backend
37 for the actual sending of the mail. If you'd like to use another backend, you
38 may set it in ``CELERY_EMAIL_BACKEND`` just like you would normally have set
39 ``EMAIL_BACKEND`` before you were using Celery. In fact, the normal installation
40 procedure will most likely be to get your email working using only Django, then
41 change ``EMAIL_BACKEND`` to ``CELERY_EMAIL_BACKEND``, and then add the new
42 ``EMAIL_BACKEND`` setting from above.
43
44 Mass email are sent in chunks of size ``CELERY_EMAIL_CHUNK_SIZE`` (defaults to 10).
45
46 If you need to set any of the settings (attributes) you'd normally be able to set on a
47 `Celery Task`_ class had you written it yourself, you may specify them in a ``dict``
48 in the ``CELERY_EMAIL_TASK_CONFIG`` setting::
49
50 CELERY_EMAIL_TASK_CONFIG = {
51 'queue' : 'email',
52 'rate_limit' : '50/m', # * CELERY_EMAIL_CHUNK_SIZE (default: 10)
53 ...
54 }
55
56 There are some default settings. Unless you specify otherwise, the equivalent of the
57 following settings will apply::
58
59 CELERY_EMAIL_TASK_CONFIG = {
60 'name': 'djcelery_email_send',
61 'ignore_result': True,
62 }
63
64 After this setup is complete, and you have a working Celery install, sending
65 email will work exactly like it did before, except that the sending will be
66 handled by your Celery workers::
67
68 from django.core import mail
69
70 emails = (
71 ('Hey Man', "I'm The Dude! So that's what you call me.", '[email protected]', ['[email protected]']),
72 ('Dammit Walter', "Let's go bowlin'.", '[email protected]', ['[email protected]']),
73 )
74 results = mail.send_mass_mail(emails)
75
76 ``results`` will be a list of celery `AsyncResult`_ objects that you may ignore, or use to check the
77 status of the email delivery task, or even wait for it to complete if want. You have to enable a result
78 backend and set ``ignore_result`` to ``False`` in ``CELERY_EMAIL_TASK_CONFIG`` if you want to use these.
79 You should also set ``CELERY_EMAIL_CHUNK_SIZE = 1`` in settings if you are concerned about task status
80 and results.
81
82 See the `Celery docs`_ for more info.
83
84
85 ``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
86 of their delivery.
87
88 .. _`Celery Task`: http://celery.readthedocs.org/en/latest/userguide/tasks.html#basics
89 .. _`Celery docs`: http://celery.readthedocs.org/en/latest/userguide/tasks.html#task-states
90 .. _`AsyncResult`: http://celery.readthedocs.org/en/latest/reference/celery.result.html#celery.result.AsyncResult
91
92 Changelog
93 =========
94
95 3.0.0 - 2019.12.10
96 ------------------
97
98 * Support for Django 3.0
99 * Support for Python 3.8
100 * Droppped support for Django 1.x, Django 2.0 and Django 2.1
101 * Droppped support for Python 2.7
102
103 2.0.2 - 2019.05.29
104 ------------------
105
106 * Reduce memory usage by running email_to_dict on chunks. Thanks `Paul Brown`_.
107 * Simplify dict_to_email for readability and efficiency. Thanks `Paul Brown`_.
108 * Update test matrix for supported versions of Django, Celery and Python. Thanks `James`_.
109
110 .. _Paul Brown: https://github.com/pawl
111 .. _James: https://github.com/jmsmkn
112
113 2.0.1 - 2018.18.27
114 ------------------
115 * Fix bug preventing sending text/* encoded mime attachments. Thanks `Cesar Canassa`_.
116
117 .. _Cesar Canassa: https://github.com/canassa
118
119 2.0 - 2017.07.10
120 ----------------
121 * Support for Django 1.11 and Celery 4.0
122 * Dropped support for Celery 2.x and 3.x
123 * Dropped support for Python 3.3
124
125 1.1.5 - 2016.07.20
126 ------------------
127 * Support extra email attributes via CELERY_EMAIL_MESSAGE_EXTRA_ATTRIBUTES setting
128 * Updated version requirements in README
129
130
131 1.1.4 - 2016.01.19
132 ------------------
133
134 * Support sending email with embedded images. Thanks `Georg Zimmer`_.
135 * Document CELERY_EMAIL_CHUNK_SIZE. Thanks `Jonas Haag`_.
136 * Add exception handling to email backend connection. Thanks `Tom`_.
137
138 .. _Georg Zimmer: https://github.com/georgmzimmer
139 .. _Tom: https://github.com/tomleo
140
141 1.1.3 - 2015.11.06
142 ------------------
143
144 * Support setting celery.base from string. Thanks `Matthew Jacobi`_.
145 * Use six for py2/3 string compatibility. Thanks `Matthew Jacobi`_.
146 * Pass content_subtype back in for retries. Thanks `Mark Joshua Tan`_.
147 * Rework how tests work, add tox, rework travis-ci matrix.
148 * Use six from django.utils.
149 * Release a universal wheel.
150
151 .. _Matthew Jacobi: https://github.com/oppianmatt
152 .. _Mark Joshua Tan: https://github.com/mark-tan
153
154 1.1.2 - 2015.07.06
155 ------------------
156
157 * Fix for HTML-only emails. Thanks `gnarvaja`_.
158
159 .. _gnarvaja: https://github.com/gnarvaja
160
161 1.1.1 - 2015.03.20
162 ------------------
163
164 * Fix for backward compatibility of task kwarg handling - Thanks `Jeremy Thurgood`_.
165
166 .. _Jeremy Thurgood: https://github.com/jerith
167
168 1.1.0 - 2015.03.06
169 ------------------
170
171 * New PyPI release rolling up 1.0.5 changes and some cleanup.
172 * More backward compatability in task. Will still accept message objects and lists of message objects.
173 * Thanks again to everyone who contributed to 1.0.5.
174
175 1.0.5 - 2014.08.24
176 ------------------
177
178 * Django 1.6 support, Travis CI testing, chunked sending & more - thanks `Jonas Haag`_.
179 * HTML email support - thanks `Andres Riancho`_.
180 * Support for JSON transit for Celery, sponsored by `DigiACTive`_.
181 * Drop support for Django 1.2.
182
183 .. _`Jonas Haag`: https://github.com/jonashaag
184 .. _`Andres Riancho`: https://github.com/andresriancho
185 .. _`DigiACTive`: https://github.com/digiactive
186
187 1.0.4 - 2013.10.12
188 ------------------
189
190 * Add Django 1.5.2 and Python 3 support.
191 * Thanks to `Stefan Wehrmeyer`_ for the contribution.
192
193 .. _`Stefan Wehrmeyer`: https://github.com/stefanw
194
195 1.0.3 - 2012.03.06
196 ------------------
197
198 * Backend will now pass any kwargs with which it is initialized to the
199 email sending backend.
200 * Thanks to `Fedor Tyurin`_ for the contribution.
201
202 .. _`Fedor Tyurin`: https://bitbucket.org/ftyurin
203
204
205 1.0.2 - 2012.02.21
206 ------------------
207
208 * Task and backend now accept kwargs that can be used in signal handlers.
209 * Task now returns the result from the email sending backend.
210 * Thanks to `Yehonatan Daniv`_ for these changes.
211
212 .. _`Yehonatan Daniv`: https://bitbucket.org/ydaniv
213
214 1.0.1 - 2011.10.06
215 ------------------
216
217 * Fixed a bug that resulted in tasks that were throwing errors reporting success.
218 * If there is an exception thrown by the sending email backend, the result of the task will
219 now be this exception.