SPF ~all vs -all: which one to publish, and what DMARC does with each
The last mechanism in an SPF record decides what a receiver is told to do with mail from a sender you did not list: v=spf1 include:_spf.google.com ~all v=spf1 include:_spf.google.com -all What the quali
The last mechanism in an SPF record decides what a receiver is told to do with mail from a sender you did not list:
v=spf1 include:_spf.google.com ~all
v=spf1 include:_spf.google.com -all
What the qualifiers mean
-
-all(fail): the sending IP is not authorised. Mail should not be trusted. -
~all(softfail): probably not authorised, but accept it and treat it with suspicion. -
?all(neutral): no statement. Avoid it on a real domain. -
+all: everyone is authorised. This is never what you want.
What actually happens at the receiver
SPF alone is advisory. Many large receivers do not reject on -all by themselves. They record the SPF result and feed it into their spam scoring and, if you publish one, your DMARC policy.
DMARC passes if SPF or DKIM passes and is aligned with the From: domain. So:
- A message that fails SPF but has a valid, aligned DKIM signature still passes DMARC.
~alland-allmake no difference to that outcome. - A message that fails both is judged by your DMARC
p=value (none, quarantine, reject), not by the SPF qualifier. - Some receivers do reject on
-allbefore DMARC is ever evaluated. The DMARC specification warns about this, because it can discard mail that a valid DKIM signature would have rescued. Mailing lists and forwarders trip this most often, since forwarding breaks SPF.
Which one to publish
- If you enforce DMARC (
p=quarantineorp=reject) and sign everything with DKIM,~allis the safer choice. DMARC does the enforcing, and you avoid early rejection of forwarded mail. - If you do not sign with DKIM everywhere, fix that first. Switching to
-alldoes not make a weak setup stronger, it only makes failures harder. - Use
-allfor domains that never send mail (a parked domain, or a legacy domain that only redirects):v=spf1 -all, together withp=rejectin DMARC.
Check before you change it
- List every system that sends as your domain: your mail platform, invoicing, CRM, helpdesk, newsletters, website forms.
- For each one, confirm DKIM signs with your domain, not the vendor's.
- Read a week or two of DMARC aggregate reports and look for sources you do not recognise.
- Count DNS lookups. SPF is limited to 10 lookups, and a record over the limit returns a permanent error regardless of
~allor-all.
Then change the qualifier, and re-read the reports a week later. The qualifier is the easy part. Knowing every sender is what makes a change safe, and senders change every few months.
Inspect your live SPF, DKIM & DMARC alignment free in 5 seconds: https://email-fix-pack.pages.dev/?src=devto
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.