Mercurial > public > sg101
diff core/functions.py @ 893:3aecf9058130
Merge with upstream.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 17 Feb 2015 18:59:06 -0600 |
parents | 79a71b9d0a2a |
children | 51a2051588f5 |
line wrap: on
line diff
--- a/core/functions.py Tue Feb 10 20:36:34 2015 -0600 +++ b/core/functions.py Tue Feb 17 18:59:06 2015 -0600 @@ -23,7 +23,7 @@ os.remove(path) -def send_mail(subject, message, from_email, recipient_list, defer=True, **kwargs): +def send_mail(subject, message, from_email, recipient_list, reply_to=None, defer=True): """ The main send email function. Use this function to send email from the site. All applications should use this function instead of calling @@ -39,15 +39,23 @@ logging.warning("Empty recipient_list in send_mail") return - logging.debug('EMAIL:\nFrom: %s\nTo: %s\nSubject: %s\nMessage:\n%s', - from_email, str(recipient_list), subject, message) + logging.debug('EMAIL:\nFrom: %s\nTo: %s\nReply-To: %s\nSubject: %s\nMessage:\n%s', + from_email, str(recipient_list), reply_to, subject, message) + + headers = {'Reply-To': reply_to} if reply_to else None + msg_kwargs = { + 'subject': subject, + 'body': message, + 'from_email': from_email, + 'to': recipient_list, + 'headers': headers, + } if defer: - core.tasks.send_mail.delay(subject, message, from_email, recipient_list, - **kwargs) + core.tasks.send_mail.delay(**msg_kwargs) else: - django.core.mail.send_mail(subject, message, from_email, recipient_list, - **kwargs) + msg = django.core.mail.EmailMessage(**msg_kwargs) + msg.send() def email_admins(subject, message):