Make sure all requirements are properly setup.
Get it from the Cheese Shop:
pip install django-newsletter
Or get the latest & greatest from Github and link it to your application tree:
pip install -e git://github.com/dokterbob/django-newsletter.git#egg=django-newsletter
(In either case it is recommended that you use VirtualEnv in order to keep your Python environment somewhat clean.)
Add newsletter to
INSTALLED_APPSin settings.py and make sure that your favourite rich text widget (optional), some Django contrib dependencies, sorl-thumbnail and django-extensions (the latter is used for the submission jobs) are there as well:
INSTALLED_APPS = ( 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.auth', 'django.contrib.sites', ... # Imperavi (or tinymce) rich text editor is optional # 'imperavi', 'django_extensions', 'sorl.thumbnail', ... 'newsletter', ... )
Disable email confirmation for subscribe, unsubscribe and update actions for subscriptions.
By default subscribe, unsubscribe and update requests made by a user who is not logged in need to be confirmed by clicking on an activation link in an email. If you want all requested actions to be performed without email confirmation, add following line to settings.py:
NEWSLETTER_CONFIRM_EMAIL = False
For more granular control the
NEWSLETTER_CONFIRM_EMAILsetting can be overridden for each of subscribe, unsubscribe and update actions, by adding
Install and configure your preferred rich text widget (optional).
# Using django-imperavi NEWSLETTER_RICHTEXT_WIDGET = "imperavi.widget.ImperaviWidget" # Using django-tinymce NEWSLETTER_RICHTEXT_WIDGET = "tinymce.widgets.TinyMCE"
If not set, django-newsletter will fall back to Django’s default TextField widget.
Configure delay and batch size (optional).
The delay between each email, batches en batch size can be specified with e.g.:
# Amount of seconds to wait between each email. Here 100ms is used. ``NEWSLETTER_EMAIL_DELAY = 0.1`` # Amount of seconds to wait between each batch. Here one minute is used. ``NEWSLETTER_BATCH_DELAY = 60`` # Number of emails in one batch ``NEWSLETTER_BATCH_SIZE = 100``
For both delays, sub-second delays can also be used. If the delays are not set, it will default to not sleeping.
Import subscription, unsubscription and archive URL’s somewhere in your urls.py:
urlpatterns = [ ... url(r'^newsletter/', include('newsletter.urls')), ... ]
Create the required data structure:
Change the default contact email listed in
(Optionally) Create message template overrides for specific newsletters in
<message_type>can be one from subscribe, unsubscribe, message or update.
Add jobs for sending out mail queues to crontab:
@hourly /path/to/my/project/manage.py runjobs hourly @daily /path/to/my/project/manage.py runjobs daily @weekly /path/to/my/project/manage.py runjobs weekly @monthly /path/to/my/project/manage.py runjobs monthly
To send mail,
django-newsletter uses Django-provided email utilities, so
ensure that email settings are
properly configured for your project.