Django Electronic Digest

Is there an existing plugin for creating daily or weekly emails in Django? (We want to combine many small notifications into one email address, rather than constantly bothering people.)

Django-mailer claims that it supports, but they tell me that it really is not.

+6
django email django-email django-mailer
source share
2 answers

There is a django-mailer application that I still did not know about, so the answer below describes my own approach.

The simplest case does not require much:

put this in your app/management/commands/send_email_alerts.py and then configure the cron job to run this command once a week using python manage.py send_email_alerts (all paths must be set in the environment, of course, for manage.py to choose your application settings)

 from django.core.management.base import NoArgsCommand from django.db import connection from django.core.mail import EmailMessage class Command(NoArgsCommand): def handle_noargs(self,**options): try: self.send_email_alerts() except Exception, e: print e finally: connection.close() def send_email_alerts(self): for user in User.objects.all(): text = 'Hi %s, here the news' % user.username subject = 'some subject' msg = EmailMessage(subject, text, settings.DEFAULT_FROM_EMAIL, [user.email]) msg.send() 

But if you need to keep track of what you need to send an email to each user, and how often an additional code is required. Here is an example. It is possible that django-mailer can fill in the blanks.

+4
source share

I just released the django-digested package for PyPI. It supports instant notifications, daily and weekly digests and individual preferences for different update groups.

+3
source share

All Articles