Skip to main content
Help us improve Python packaging – donate today!

A Django app for sending newsletter by email to a contact list.

Project Description

The problematic was :

How to couple a contact base to a mailing list and sending newsletters throught Django ?

Imagine that we have an application containing some kind of profiles or something like the django.contrib.auth and you want to send newsletters to them and tracking the activity.


More than a long speech, here the list of the main features :

  • Coupling capacities with another django model.
  • Variables can be used in the newsletter’s templates.
  • Mailing list managements (merging, importing…).
  • Configurable SMTP servers with flow limit management.
  • Can send newsletter previews.
  • Unsubscriptions to mailing list.
  • Unique urls for an user.
  • Tracking statistics.


At the level of the application architecture, we can see 2 originalities who need to be explained.

Content types

The content types application is used to link any Contact model instance to another model instance. This allow you to create different kinds of contact linked to differents application, and retrieve the association at anytime.

This is particulary usefull with the templates variables if certain informations are located in the model instance linked.


The emencia.django.newsletter application will never send the newsletters registered in the site until you launch the send_newsletter command.

$> python send_newsletter

This command will launch the newsletters who need to be launched accordingly to the credits of the SMTP server of the newsletter. That’s mean that not all newsletters will be expedied at the end of the command because if you use a public SMTP server you can be banished temporarly if you reach the sending limit. To avoid banishment all the newsletters are not sended in the same time and immediately.

So it is recommanded to create a cronjob for launching this command every hours for example.


First of all you need to install emencia.django.newsletter into your PYTHON_PATH.

Then register this module, admin and contenttypes in your INSTALLED_APPS section your project settings.

...   # Your favorites apps
..    'django.contrib.contenttypes',
...   'django.contrib.admin',
...   'emencia.django.newsletter',)

In your project adding this following line to include the newsletter’s urls for serving the newsletters in HTML.

>>> (r'^newsletters/', include('emencia.django.newsletter.urls')),

Now you can run a syncdb for installing the models into your database.

HOWTO couple your profile application with emencia.django.newsletter

If you wan to quickly import your contacts into a mailing list for example, you can write an admin’s action for your model.

We suppose that we have the fields email, first_name and last_name in a models name Profile.

In his AdminModel definition add this method and register it into the actions property.

>>> class ProfileAdmin(admin.ModelAdmin):
...   def make_mailing_list(self, request, queryset):
...     from emencia.django.newsletter.models import Contact
...     from emencia.django.newsletter.models import MailingList
...     subscribers = []
...     for profile in queryset:
...       contact, created = Contact.objects.get_or_create(email=profile.mail,
...                                                        defaults={'first_name': profile.first_name,
...                                                                  'last_name': profile.last_name,
...                                                                  'content_object': profile})
...     subscribers.append(contact)
...     new_mailing = MailingList(name='New mailing list',
...                               description='New mailing list created from admin/profile')
...     new_mailing.subscribers.add(*subscribers)
...     self.message_user(request, '%s succesfully created.' % new_mailing)
...   make_mailing_list.short_description = 'Create a mailing list'
...   actions = ['make_mailing_list',]

This action will create or retrieve all the Contact instances needed for the mailing list creation.

After this you can send a newsletter to this mailing list.

Database Representation


0.1dev (unreleased)

  • Initial release

Release history Release notifications

History Node


This version
History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
emencia.django.newsletter-0.1.tar.gz (114.0 kB) Copy SHA256 hash SHA256 Source None Nov 9, 2009

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page