From b4d29815802adb1b01e1c7e3e4c7ad43d5f7276e Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Thu, 6 Sep 2012 11:11:50 -0600 Subject: temporal commit: added base template and modified askbot.mail.send_mail function to support both html and plain text --- askbot/mail/__init__.py | 15 ++- .../skins/default/templates/email/base_mail.html | 148 +++++++++++++++++++++ 2 files changed, 156 insertions(+), 7 deletions(-) create mode 100644 askbot/skins/default/templates/email/base_mail.html diff --git a/askbot/mail/__init__.py b/askbot/mail/__init__.py index 7ff8a2d3..9002e501 100644 --- a/askbot/mail/__init__.py +++ b/askbot/mail/__init__.py @@ -11,6 +11,7 @@ from django.forms import ValidationError from django.utils.translation import ugettext_lazy as _ from django.utils.translation import string_concat from django.template import Context +from django.utils.html import strip_tags from askbot import exceptions from askbot import const from askbot.conf import settings as askbot_settings @@ -103,14 +104,14 @@ def send_mail( try: assert(subject_line is not None) subject_line = prefix_the_subject_line(subject_line) - msg = mail.EmailMessage( - subject_line, - body_text, + msg = mail.EmailMultiAlternatives( + subject_line, + strip_tags(body_text), from_email, recipient_list, headers = headers ) - msg.content_subtype = 'html' + msg.attach_alternative(body_text, "text/html") msg.send() if related_object is not None: assert(activity_type is not None) @@ -227,7 +228,7 @@ def bounce_email( headers = {} if reply_to: headers['Reply-To'] = reply_to - + send_mail( recipient_list = (email,), subject_line = 'Re: ' + subject, @@ -284,7 +285,7 @@ def process_parts(parts, reply_code = None): """Process parts will upload the attachments and parse out the body, if body is multipart. Secondly - links to attachments will be added to the body of the question. - Returns ready to post body of the message and the list + Returns ready to post body of the message and the list of uploaded files. """ body_markdown = '' @@ -302,7 +303,7 @@ def process_parts(parts, reply_code = None): stored_files.append(stored_file) body_markdown += markdown - #if the response separator is present - + #if the response separator is present - #split the body with it, and discard the "so and so wrote:" part if reply_code: signature = extract_user_signature(body_markdown, reply_code) diff --git a/askbot/skins/default/templates/email/base_mail.html b/askbot/skins/default/templates/email/base_mail.html new file mode 100644 index 00000000..1a507a64 --- /dev/null +++ b/askbot/skins/default/templates/email/base_mail.html @@ -0,0 +1,148 @@ + + + + + + {%block title%}{%endblock%} + + + + + + + + + + + + + + + +
+ {%block content%} + {%endblock%} +
+ + + -- cgit v1.2.3-1-g7c22