From cb92f1efeab0094b8d8e130133a5993176cbf361 Mon Sep 17 00:00:00 2001 From: Son Date: Tue, 22 Mar 2022 18:54:45 +0100 Subject: [PATCH] log when an email fails dmarc --- email_handler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/email_handler.py b/email_handler.py index 11500a6e..8f20f26f 100644 --- a/email_handler.py +++ b/email_handler.py @@ -546,13 +546,16 @@ def apply_dmarc_policy( newrelic.agent.record_custom_event( "Custom/dmarc_check", {"result": dmarc_result.name} ) + if not DMARC_CHECK_ENABLED: return None + if dmarc_result in ( DmarcCheckResult.quarantine, DmarcCheckResult.reject, DmarcCheckResult.soft_fail, ): + LOG.w(f"put email from {contact} to {alias} to quarantine. {dmarc_result}") quarantine_dmarc_failed_email(alias, contact, envelope, msg) Notification.create( user_id=alias.user_id,