log envelope mail_from and header_from when dmarc fail

This commit is contained in:
Son 2022-03-25 16:20:30 +01:00
parent 63b1100a8b
commit 17d9190309
1 changed files with 5 additions and 4 deletions

View File

@ -548,9 +548,7 @@ def apply_dmarc_policy(
"Custom/dmarc_check", {"result": dmarc_result.name} "Custom/dmarc_check", {"result": dmarc_result.name}
) )
else: else:
newrelic.agent.record_custom_event( newrelic.agent.record_custom_event("Custom/dmarc_check", {"result": "N/A"})
"Custom/dmarc_check", {"result": "N/A"}
)
if not DMARC_CHECK_ENABLED or not dmarc_result: if not DMARC_CHECK_ENABLED or not dmarc_result:
return None return None
@ -560,7 +558,10 @@ def apply_dmarc_policy(
DmarcCheckResult.reject, DmarcCheckResult.reject,
DmarcCheckResult.soft_fail, DmarcCheckResult.soft_fail,
): ):
LOG.w(f"put email from {contact} to {alias} to quarantine. {dmarc_result}") LOG.w(
f"put email from {contact} to {alias} to quarantine. {dmarc_result}, "
f"mail_from:{envelope.mail_from}, from_header: {msg[headers.FROM]}"
)
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,