Private
Public Access
1
0

bug fix in email templates

This commit is contained in:
Sander Roosendaal
2018-03-19 18:05:30 +01:00
parent 0dadcf32a6
commit ffed5c694b

View File

@@ -38,6 +38,29 @@ def textify(html):
# Strip single spaces in the beginning of each line
return text_only.replace('\n ', '\n').strip()
def send_template_email(from_email,to_email,subject,template,context,*args,**kwargs):
htmly = get_template(template)
html_content = htmly.render(context)
text_content = textify(html_content)
msg = EmailMultiAlternatives(subject, text_content, from_email, to_email)
msg.attach_alternative(html_content, "text/html")
if 'emailbounced' in kwargs:
emailbounced = kwargs['emailbounced']
else:
emailbounced = False
if not emailbounced:
res = msg.send()
else:
return 0
return res
from utils import deserialize_list
from rowers.dataprepnodjango import (
@@ -1096,21 +1119,7 @@ def handle_sendemailnewresponse(first_name, last_name,
'commentid':commentid
}
html_content = htmly.render(d)
text_content = textify(html_content)
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
msg.attach_alternative(html_content, "text/html")
if 'emailbounced' in kwargs:
emailbounced = kwargs['emailbounced']
else:
emailbounced = False
if not emailbounced:
res = msg.send()
res = send_template_email(from_email,[fullemail],subject,'teamresponseemail.html',d,**kwargs)
return 1