return only bounce report that can be decoded

This commit is contained in:
Son 2021-11-17 10:54:17 +01:00
parent 278a9d19c6
commit 9c27f94e8e
1 changed files with 8 additions and 1 deletions

View File

@ -644,7 +644,14 @@ def get_mailbox_bounce_info(bounce_report: Message) -> Optional[Message]:
if not part["content-transfer-encoding"]:
LOG.w("add missing content-transfer-encoding header")
part["content-transfer-encoding"] = "7bit"
return part
try:
part.as_bytes().decode()
except UnicodeDecodeError:
LOG.w("cannot use this bounce report")
return
else:
return part
def get_orig_message_from_hotmail_complaint(msg: Message) -> Optional[Message]: