Fix error during decoding of mail body

This commit is contained in:
2020-01-27 22:47:57 +01:00
parent 057e66f945
commit b40e835215

View File

@@ -229,15 +229,12 @@ class EMailNotification(BaseNotification):
break break
if body is not None: if body is not None:
# get the character set, fallback to utf-8 if not defined in header charset = body.get_content_charset() or "utf-8"
charset = body.get_content_charset() content = body.get_payload(decode=True)
if charset is None: try:
charset = "utf-8" content = content.decode(encoding=charset, errors="replace")
except LookupError:
# decode content content = content.decode("utf-8", errors="replace")
content = body.get_payload(decode=True).decode(
encoding=charset, errors="replace")
content_type = body.get_content_type() content_type = body.get_content_type()
if content_type == EMailNotification._plain_text: if content_type == EMailNotification._plain_text:
# convert text/plain to text/html # convert text/plain to text/html