Sender Policy Framework (SPF)

Security Glossary - Email Authentication

Definition: SPF is an email authentication protocol that allows domain owners to specify which mail servers are authorized to send email on behalf of their domain. It works through a TXT record in DNS that lists the IP addresses and hostnames allowed to send email for the domain. Receiving mail servers check the SPF record to verify the sending server is authorized.

Why SPF Is Important

Without SPF, anyone can send email that appears to come from your domain. Attackers routinely spoof sender addresses to make phishing emails look legitimate. An email from admin@yourdomain.com is much more convincing when your domain has no SPF record to contradict the forgery.

SPF alone does not prevent spoofing because it only checks the envelope sender (the Return-Path), not the From header that users see. This is why SPF must be combined with DKIM and DMARC for complete email authentication. SPF handles the "who is allowed to send" question, DKIM handles "is the message intact," and DMARC ties them together with a policy.

A common SPF mistake is exceeding the 10 DNS lookup limit. SPF evaluation requires resolving include, a, mx, and redirect mechanisms, and the spec limits this to 10 lookups. Exceeding this limit causes SPF to return a permanent error (PermError), which many receivers treat the same as a fail. Flattening SPF records or reducing includes helps stay within the limit.

Configuration Reference

SPF MechanismPurposeExample
includeAuthorize third-party sendersinclude:_spf.google.com
ip4Authorize specific IPv4ip4:192.168.1.0/24
aAuthorize domain's A record IPsa:mail.example.com
mxAuthorize domain's MX IPsmx
~allSoft fail non-matchingRecommended during testing
-allHard fail non-matchingRecommended for production

Checking Your Setup

Use a DNS health checker to verify your SPF record is present, syntactically correct, and within the 10-lookup limit. The tool validates each mechanism in the record and checks that all included domains resolve correctly. Run a check after adding any new email sending service.

Common Questions About SPF

What should my SPF record look like?
A typical SPF record looks like: v=spf1 include:_spf.google.com include:sendgrid.net -all. This authorizes Google Workspace and SendGrid to send on your behalf, and -all rejects everything else. Replace the includes with your actual email providers.
What is the difference between ~all and -all?
~all (soft fail) marks unauthorized senders as suspicious but does not reject them. -all (hard fail) tells receivers to reject unauthorized senders. Use -all for stronger protection once you have confirmed all legitimate senders are included in your SPF record.
Disclaimer: DomainOptic provides automated informational scans only. Results do not constitute professional security advice, compliance certification, or a guarantee of security. Always verify findings independently.