From a2fcfbbb20c709949e1f2665b722ee96901c45ee Mon Sep 17 00:00:00 2001 From: Son Date: Tue, 19 Oct 2021 12:05:35 +0200 Subject: [PATCH] use as_bytes().decode() instead of as_string() in bounce_info --- email_handler.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/email_handler.py b/email_handler.py index 43d102ea..b49faf0d 100644 --- a/email_handler.py +++ b/email_handler.py @@ -1250,7 +1250,9 @@ def handle_bounce_forward_phase(msg: Message, email_log: EmailLog): bounce_info = get_mailbox_bounce_info(msg) if bounce_info: - Bounce.create(email=mailbox.email, info=bounce_info.as_string(), commit=True) + Bounce.create( + email=mailbox.email, info=bounce_info.as_bytes().decode(), commit=True + ) else: LOG.w("cannot get bounce info") Bounce.create(email=mailbox.email, commit=True) @@ -1456,7 +1458,7 @@ def handle_bounce_reply_phase(envelope, msg: Message, email_log: EmailLog): if bounce_info: Bounce.create( email=sanitize_email(contact.website_email), - info=bounce_info.as_string(), + info=bounce_info.as_bytes().decode(), commit=True, ) else: @@ -1719,7 +1721,9 @@ def handle_transactional_bounce(envelope: Envelope, msg, rcpt_to): bounce_info = get_mailbox_bounce_info(msg) if bounce_info: Bounce.create( - email=transactional.email, info=bounce_info.as_string(), commit=True + email=transactional.email, + info=bounce_info.as_bytes().decode(), + commit=True, ) else: LOG.w("cannot get bounce info")