Created
November 25, 2013 00:38
-
-
Save yuchant/7634542 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_html_mail(subject, message, message_html, from_email, recipient_list, | |
priority="medium", fail_silently=False, auth_user=None, | |
auth_password=None, account=0, attachments=None, headers=None): | |
""" | |
Ripped out of mailer.. does not accept headers. | |
""" | |
from django.utils.encoding import force_unicode | |
from django.core.mail import EmailMultiAlternatives | |
from mailer.models import make_message | |
priority = PRIORITY_MAPPING[priority] | |
# need to do this in case subject used lazy version of ugettext | |
subject = force_unicode(subject) | |
message = force_unicode(message) | |
msg = make_message(subject=subject, | |
body=message, | |
from_email=from_email, | |
to=recipient_list, | |
priority=priority, | |
attachments=None, | |
account=account) | |
email = msg.email | |
email = EmailMultiAlternatives(email.subject, email.body, email.from_email, email.to) | |
email.attach_alternative(message_html, "text/html") | |
email.extra_headers.update(headers or {}) | |
msg.email = email | |
msg.save() | |
return 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment