For SpamAssassin 3.4.2 I've added the below configuration ruleset to local.cf
with the intent of providing a spam score for failed DMARC tests.
The DMARC and SPF Authentication-Results headers are created by opendmarc
and the DKIM Authentication-Results header by opendkim
.
The expected output is a score for all three header results added to the X-Spam-Report header.
The actual output is only for a domain that has p=reject
or p=none
with the appropriate score added to the X-Spam-Report header, but for p=quarantine
nothing is added to the X-Spam-Report header even though the DMARC, DKIM and SPF Authentication-Results headers have been added as expected.
Added to /etc/spamassassin/local.cf
:
ifplugin Mail::SpamAssassin::Plugin::AskDNS
askdns __DMARC_POLICY_NONE _dmarc._AUTHORDOMAIN_ TXT /^v=DMARC1;.*\bp=none;/
askdns __DMARC_POLICY_QUAR _dmarc._AUTHORDOMAIN_ TXT /^v=DMARC1;.*\bp=quarantine;/
askdns __DMARC_POLICY_REJECT _dmarc._AUTHORDOMAIN_ TXT /^v=DMARC1;.*\bp=reject;/
meta DMARC_REJECT !(DKIM_VALID_AU || SPF_PASS) && __DMARC_POLICY_REJECT
score DMARC_REJECT 10
meta DMARC_QUAR !(DKIM_VALID_AU || SPF_PASS) && __DMARC_POLICY_QUAR
score DMARC_QUAR 5
meta DMARC_NONE !(DKIM_VALID_AU || SPF_PASS) && __DMARC_POLICY_NONE
score DMARC_NONE 0.1
endif # Mail::SpamAssassin::Plugin::AskDNS
What is wrong with the configuration?
The configuration you refer to is copied from Random Thoughts blog on DMARC / Spamassassin / Qmail. This blog post gives AskDNS as a third option if you can't use OpenDMARC for some reason. As you are already using OpenDMARC, you can directly use its
Authentication-Results
header in SpamAssassin. Modified from David Jones:If you have implemented OpenDMARC to connection-stage reject the messages that fail DMARC checks with
p=reject
, your SpamAssassin will never see any messages falling to the fourth category, but here it is, just for completeness:Because the
Authentication-Results
headers can also be forged, I wouldn't give high negative score based on them alone. Therefore, the most useful rule here is theDMARC_FAIL
, firing onp=quarantine
. In my opinion, that could also give score more than the5.0
in this example, as the decision is already made by the sending domain.If the above example configuration is not suitable, here is an additional configuration and scoring option: