forked from pinax/django-mailer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
38 lines (27 loc) · 2.03 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
>>>django-mailer by James Tauber <http://jtauber.com/>
>>>http://code.google.com/p/django-mailer/
>>>A reusable Django app for queuing the sending of email
Add possibility to sending email from second queue and authorization. For using it, you should provide additional (bool) 'is_mass' parameter into sending functions.
If True, application will use EMAIL_HOST_USER_MASS and EMAIL_HOST_PASSWORD_MASS parameters from settings.py for authorization. Many smtp servers check, if "from_email" param coincide with authorization username, and they return error if no. To avoid it, pass "from_email" param manually. Also there is next algorithm in sendin: email is sent in some attempts with interval between them. There is some settings for managing them:
MAILER_MASS_QUEUE_SIZE = <int> # Count of letters in one attempt
MAILER_MASS_QUEUE_INTERVAL = <int> # Interval in minutes between attempts
MAILER_MASS_QUEUE_ATTEMPTS = <int> # Count of attempts
All additional parameters is required
EXAMPLES
settings.py:
EMAIL_HOST_USER = 'user1@gmail.com'
EMAIL_HOST_PASSWORD = 'password1'
EMAIL_HOST_USER_MASS = 'user2@gmail.com'
EMAIL_HOST_PASSWORD_MASS = 'password2'
MAILER_MASS_QUEUE_SIZE = 5
MAILER_MASS_QUEUE_INTERVAL = 1
MAILER_MASS_QUEUE_ATTEMPTS = 3
sending email:
from django.conf import settings
import mailer
mailer.send_html_mail('Email subject', 'email text', '<b>email text</b>', from_email=settings.EMAIL_HOST_USER, recipient_list=('to_email@gmail.com',))
# Message will be sent with EMAIL_HOST_USER and EMAIL_HOST_PASSWORD authorization
mailer.send_html_mail('Email subject', 'email text', '<b>email text</b>', from_email=settings.EMAIL_HOST_USER_MASS, recipient_list=('to_email@gmail.com',), is_mass=True)
# Message will be sent with EMAIL_HOST_USER_MASS and EMAIL_HOST_PASSWORD_MASS authorization and will be use attempts algorithm.
python manage.py send_mail ; starting sending for letters with is_mass=False (by default)
python manage.py send_mass_mail ; starting sending for letters with is_mass=True. Letters will be sent in 3 attempts with 5 units in each one.