Send emails out to users on major Group changes

This commit is contained in:
2011-09-30 09:16:21 +01:00
parent 0c3e09bcf8
commit 23a5df5eda
8 changed files with 39 additions and 14 deletions

15
app/groups/utils.py Normal file
View File

@@ -0,0 +1,15 @@
from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template
from django.template import Context
def send_group_mail(request, to_email, subject, email_text_template, email_html_template):
"""Sends a email to a group of people using a standard layout"""
# Mail the admins to inform them of a new request
ctx = Context({'request': obj})
to_email = group.admins.values_list('email', flat=True)
msg = EmailMultiAlternatives(subject, get_template(email_text_template).render(ctx), getattr(settings, 'SERVER_EMAIL', 'auth@pleaseignore.com'), to_email)
msg.attach_alternative(get_template(email_html_template).render(ctx), 'text/html')
mag.send(fail_silently=True)