fix encoding of text and html parts

This commit is contained in:
2021-10-04 23:01:43 +02:00
parent 07ac65dd6b
commit 5a1e173771

View File

@@ -268,7 +268,9 @@ class AddDisclaimer:
content = f"{text_content}{text_template}" content = f"{text_content}{text_template}"
text_body.set_content( text_body.set_content(
content.encode(), maintype="text", subtype="plain") content.encode(errors="replace"),
maintype="text",
subtype="plain")
text_body.set_param("charset", "UTF-8", header="Content-Type") text_body.set_param("charset", "UTF-8", header="Content-Type")
del text_body["MIME-Version"] del text_body["MIME-Version"]
@@ -291,7 +293,9 @@ class AddDisclaimer:
body.append(html_template) body.append(html_template)
html_body.set_content( html_body.set_content(
str(soup).encode(), maintype="text", subtype="html") str(soup).encode(errors="replace"),
maintype="text",
subtype="html")
html_body.set_param("charset", "UTF-8", header="Content-Type") html_body.set_param("charset", "UTF-8", header="Content-Type")
del html_body["MIME-Version"] del html_body["MIME-Version"]