From 39ec64f1e3ba69f2b83c09afbceee31760950b93 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Fri, 17 Jul 2020 18:36:53 +0530 Subject: [PATCH] fix: add default email policy to mail body the default policy encodes special characters correctly, and is not set by _default_ unless python3.8 is used. so we'll explicitly define the policy to be used for the email body Signed-off-by: Chinmay D. Pai --- frappe/email/email_body.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frappe/email/email_body.py b/frappe/email/email_body.py index 8340d81917..d21d9290fb 100755 --- a/frappe/email/email_body.py +++ b/frappe/email/email_body.py @@ -11,6 +11,7 @@ import email.utils from six import iteritems, text_type, string_types from email.mime.multipart import MIMEMultipart from email.header import Header +from email import policy def get_email(recipients, sender='', msg='', subject='[No Subject]', @@ -68,7 +69,7 @@ class EMail: self.subject = subject self.expose_recipients = expose_recipients - self.msg_root = MIMEMultipart('mixed') + self.msg_root = MIMEMultipart('mixed', policy=policy.default) self.msg_alternative = MIMEMultipart('alternative') self.msg_root.attach(self.msg_alternative) self.cc = cc or [] @@ -238,7 +239,7 @@ class EMail: """validate, build message and convert to string""" self.validate() self.make() - return self.msg_root.as_string() + return self.msg_root.as_string(policy=policy.default) def get_formatted_html(subject, message, footer=None, print_html=None, email_account=None, header=None, unsubscribe_link=None, sender=None):