7or8bit-decode #5
1 changed files with 8 additions and 5 deletions
|
@ -55,14 +55,17 @@ def decode_email(message: email.message.Message) -> email.message.Message:
|
|||
|
||||
:param message: email.message.Message to be decoded
|
||||
:return: decoded email.message.Message"""
|
||||
if message.is_multipart():
|
||||
payload = []
|
||||
|
||||
for part in message.walk():
|
||||
if not part.is_multipart():
|
||||
payload.append(part.get_payload(decode=True))
|
||||
|
||||
message["Content-Transfer-Encoding"] = "7bit"
|
||||
message.set_payload(payload)
|
||||
else:
|
||||
message.set_payload(message.get_payload(decode=True))
|
||||
|
||||
message["Content-Transfer-Encoding"] = "7bit"
|
||||
|
||||
return message
|
||||
|
||||
|
|
Loading…
Reference in a new issue