The short answer: -all in an SPF DNS record means that only the mail servers listed in that record are authorized to send email for your domain, and all other servers are explicitly told to reject or mark the email as spam. It is the strictest and most secure SPF setting, and for most domains it is the correct choice once you have verified that every legitimate sender is included in the record.
What Is an SPF Record?
SPF (Sender Policy Framework) is an email authentication method defined in RFC 7208. It lets a domain owner publish a list of IP addresses or hostnames that are allowed to send email from that domain. When a receiving mail server gets a message claiming to be from your domain, it checks the SPF record (a specially formatted TXT record in your DNS) to see if the sending server is on the allowed list. If it is not, the message can be rejected or flagged as spam.
An SPF record always starts with v=spf1 and then contains a series of mechanisms and qualifiers. The mechanisms specify which servers are allowed (for example, ip4:192.0.2.1 or include:_spf.example.com). The qualifiers tell the receiving server what to do if a mechanism does not match. The most common qualifiers are:
+(pass) – the default, no need to write it~(softfail) – the message is not authorized, but should be accepted with a warning-(fail) – the message is not authorized and should be rejected
The -all at the end of the record is the “fail” qualifier applied to the catch-all mechanism all. It means: “if the sending server did not match any of the earlier mechanisms, then the SPF check fails.”
How SPF Authentication Works
When a mail server receives an email, it can perform an SPF check by looking up the envelope sender domain (the domain in the MAIL FROM command, not necessarily the From: header). The receiving server queries the DNS for a TXT record at that domain. If it finds an SPF record, it evaluates the mechanisms in order. The first mechanism that matches determines the result. If none match, the final all mechanism applies.
For example, consider this SPF record:
v=spf1 ip4:192.0.2.10 include:_spf.example.com -all
If a message arrives from IP 192.0.2.10, it matches ip4 and passes. If it comes from a server listed in _spf.example.com, it passes. If it comes from any other IP, the -all causes the SPF result to be fail. The receiving server can then decide to reject the email or mark it as spam.
Why Choose -all vs. ~all?
The two most common endings are -all (hard fail) and ~all (softfail). The difference is in how strictly the receiving server should treat unauthorized mail.
- -all: The domain owner is saying “I guarantee that no other server is allowed to send mail for this domain.” Receiving servers are more likely to reject the email outright.
- ~all: The domain owner is saying “I don’t think other servers are allowed, but I’m not 100% sure.” The email is typically accepted but marked as suspicious.
Most experts recommend -all for domains that have a complete and accurate list of sending servers. However, if you are still testing or if you have third-party services that might send from unknown IPs, ~all is safer because it reduces the chance of legitimate email being rejected.
How to Choose the Right SPF Ending
Choosing between -all and ~all depends on your situation. Here is a practical guide:
- Audit all legitimate senders: Make a list of every service that sends email for your domain – your own mail server, your email marketing platform, your CRM, your transactional email provider, etc.
- Check if you can list them all: If you can specify every sender with
ip4,ip6, orinclude, then-allis safe. - If you are unsure: Use
~alltemporarily while you monitor your email logs for any legitimate senders that are missing. - Test with a tool: Use an SPF checker to see which servers are currently passing and which are failing.
- Update your record: Once you are confident, change to
-alland monitor for a few weeks.
Remember that SPF only checks the envelope sender, not the visible From: header. This is why SPF alone is not enough to prevent spoofing – that is why DMARC exists.
Common Problems with -all
Using -all can cause problems if you have a misconfiguration. The most common issue is that you forget to include a legitimate sending server, and then all email from that server starts failing SPF checks. This can lead to your email being rejected by recipients.
Another issue is that SPF has a limit of 10 DNS lookups. If your record uses many include mechanisms, you might exceed that limit, causing the SPF check to return a permerror (permanent error) and the email may be treated as if SPF is not set up at all. This is a common reason why a domain with -all still sees spoofed emails passing.
Also, SPF does not protect against a sender that forges the From: header but uses a different envelope sender. That is why you should always combine SPF with DKIM and DMARC.
SPF vs. DKIM vs. DMARC
SPF is just one part of email authentication. DKIM (DomainKeys Identified Mail) uses a digital signature to verify that the message was not altered in transit. DMARC (Domain-based Message Authentication, Reporting, and Conformance) tells receiving servers what to do if both SPF and DKIM fail, and also provides a way for you to receive reports about authentication failures.
SPF alone is not sufficient to stop spoofing because it only checks the envelope sender. A spammer can send an email with your domain in the From: header but use a different envelope sender that passes SPF. DMARC aligns the From: domain with the SPF and DKIM results, so it is the real protection against direct domain spoofing.
Cost and Maintenance
There is no direct cost to adding an SPF record – it is just a DNS TXT record. However, there is an ongoing maintenance cost: you must keep the record up to date. Whenever you add a new email service or change your mail server IP, you need to update the SPF record. If you forget, your legitimate email may start failing SPF checks.
It is also important to remember that SPF records are public. Anyone can look up your SPF record and see which IP addresses are allowed to send email. This is not a security risk per se, but it means you should not include IP addresses that you do not control.
Frequently Asked Questions
What does -all mean in SPF?
-all means that if a sending server is not listed in the SPF record, the SPF check fails. This is the strictest setting and tells receiving servers to reject the email.
Should I use -all or ~all?
Use -all if you are certain that your SPF record lists every legitimate sender. Use ~all if you are still testing or if you have third-party senders that you cannot fully enumerate. Many experts recommend starting with ~all and moving to -all after verification.
Can -all break my email delivery?
Yes, if you have a legitimate sender that is not in your SPF record, that sender’s email will fail SPF and may be rejected. Always audit your senders before switching to -all.
How do I add an SPF record with -all?
Create a TXT record in your DNS with the value v=spf1 ... -all, where ... includes your allowed servers. For example: v=spf1 ip4:192.0.2.10 include:_spf.example.com -all.
Is -all enough to stop email spoofing?
No. SPF only checks the envelope sender, so a spammer can still spoof your domain in the From: header. You need DMARC to enforce alignment.