Skip to content

Commit

Permalink
support for html_message argumen in late Django version
Browse files Browse the repository at this point in the history
  • Loading branch information
ramusus committed Sep 14, 2015
1 parent 1fa3164 commit cea0001
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion email_html/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = (0, 1, 8)
VERSION = (0, 1, 9)
__version__ = '.'.join(map(str, VERSION))
6 changes: 4 additions & 2 deletions email_html/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from .templatetags.email_html import html2text, extract_urllinks


def send_mail(subject, message, from_email=None, recipient_list=None, fail_silently=False, auth_user=None,
auth_password=None, connection=None):
def send_mail(subject, message=None, from_email=None, recipient_list=None, fail_silently=False, auth_user=None,
auth_password=None, connection=None, html_message=None):
"""
Replacement for monkey-patching Django's send_mail function for sending html email by default
"""
Expand All @@ -19,6 +19,8 @@ def send_mail(subject, message, from_email=None, recipient_list=None, fail_silen
from_email = from_email or settings.DEFAULT_FROM_EMAIL
subject = settings.EMAIL_SUBJECT_PREFIX + subject.replace('\n', '')

message = html_message or message

if message.find('<html') != -1:
message_plaintext = html2text(extract_urllinks(message))
message_plaintext = re.sub(r'http://\n', 'http://', message_plaintext)
Expand Down

0 comments on commit cea0001

Please sign in to comment.