From f6fd97ef0516a4e33c06db15f45ff30ece3707e1 Mon Sep 17 00:00:00 2001 From: Son Nguyen Kim Date: Mon, 20 Sep 2021 13:54:29 +0200 Subject: [PATCH] log total number of email log for an alias when it is rate limited --- email_handler.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/email_handler.py b/email_handler.py index 38f13384..ef0a6fbd 100644 --- a/email_handler.py +++ b/email_handler.py @@ -1850,6 +1850,17 @@ def handle(envelope: Envelope) -> str: if rate_limited(mail_from, rcpt_tos): LOG.w("Rate Limiting applied for mail_from:%s rcpt_tos:%s", mail_from, rcpt_tos) + + # add more logging info. TODO: remove + if len(rcpt_tos) == 1: + alias = Alias.get_by(email=rcpt_tos[0]) + if alias: + LOG.w( + "total number email log on %s is %s", + alias, + EmailLog.query.filter(EmailLog.alias_id == alias.id).count(), + ) + if should_ignore_bounce(envelope.mail_from): return status.E207 else: