From 54f806fc4dfbbebfc7f15d20ba602090c5808ad3 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Wed, 2 Jun 2021 11:46:00 +0200 Subject: [PATCH] handle icloud bounce --- email_handler.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/email_handler.py b/email_handler.py index 717993fa..a9e3cff4 100644 --- a/email_handler.py +++ b/email_handler.py @@ -1596,6 +1596,19 @@ def handle(envelope: Envelope) -> str: email_log = EmailLog.get(email_log_id) return handle_bounce(envelope, email_log, msg) + # iCloud returns the bounce with mail_from=bounce+{email_log_id}+@simplelogin.co, rcpt_to=alias + if len(rcpt_tos) == 1 and mail_from.startswith(BOUNCE_PREFIX): + email_log_id = parse_id_from_bounce(mail_from) + email_log = EmailLog.get(email_log_id) + alias = Alias.get_by(email=rcpt_tos[0]) + LOG.e( + "iCloud bounces %s %s msg=%s", + email_log, + alias, + msg.as_string(), + ) + return handle_bounce(envelope, email_log, msg) + # Whether it's necessary to apply greylisting if greylisting_needed(mail_from, rcpt_tos): LOG.w("Grey listing applied for mail_from:%s rcpt_tos:%s", mail_from, rcpt_tos)