You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
673 B
19 lines
673 B
# -*- coding: utf-8 -*-
|
|
from django.template.loader import render_to_string
|
|
from django.core.mail import EmailMessage
|
|
from django.conf import settings
|
|
|
|
|
|
FEEDBACK_EMAILS = getattr(settings, 'FEEDBACK_EMAILS', None)
|
|
|
|
|
|
def mail_feedback(form, fail_silently=False):
|
|
recipients = FEEDBACK_EMAILS
|
|
if not recipients:
|
|
if not fail_silently:
|
|
raise Exception('no recipients; could not send email')
|
|
return False
|
|
|
|
email_body = render_to_string('feedback/mail.txt', {'data': form.cleaned_data})
|
|
email = EmailMessage(subject=u'Сообщение администрации', to=recipients, body=email_body)
|
|
return email.send(fail_silently)
|
|
|