log when an email fails dmarc

This commit is contained in:
Son 2022-03-22 18:54:45 +01:00
parent e11c257571
commit cb92f1efea

View file

@ -546,13 +546,16 @@ def apply_dmarc_policy(
newrelic.agent.record_custom_event( newrelic.agent.record_custom_event(
"Custom/dmarc_check", {"result": dmarc_result.name} "Custom/dmarc_check", {"result": dmarc_result.name}
) )
if not DMARC_CHECK_ENABLED: if not DMARC_CHECK_ENABLED:
return None return None
if dmarc_result in ( if dmarc_result in (
DmarcCheckResult.quarantine, DmarcCheckResult.quarantine,
DmarcCheckResult.reject, DmarcCheckResult.reject,
DmarcCheckResult.soft_fail, DmarcCheckResult.soft_fail,
): ):
LOG.w(f"put email from {contact} to {alias} to quarantine. {dmarc_result}")
quarantine_dmarc_failed_email(alias, contact, envelope, msg) quarantine_dmarc_failed_email(alias, contact, envelope, msg)
Notification.create( Notification.create(
user_id=alias.user_id, user_id=alias.user_id,