SecDNS

SPF (Sender Policy Framework)

SPF is an email authentication mechanism that lets a domain owner publish, via a TXT record, which IP addresses are authorised to send mail on the domain's behalf.

SPF (Sender Policy Framework)

SPF (Sender Policy Framework) is an email authentication mechanism whose policy, published as a TXT record at the apex of a domain, lists the IP ranges and hosts that are permitted to send mail on behalf of that domain.

In plain English

If you only send mail from Google Workspace and SendGrid, you publish an SPF record saying so. Mail servers that receive a message claiming to be from your domain can then check the sender IP against your SPF policy and reject the message if the IP is not on the list.

How it works

SPF is defined in RFC 7208. The record is a TXT at the apex (or at a sending sub-domain) starting with v=spf1, followed by mechanisms (include:, ip4:, ip6:, a, mx, exists, ptr) and a final qualifier (-all, ~all, ?all, +all). Receivers compute the sending IP against this policy and return Pass, Fail, SoftFail, Neutral, None, PermError, or TempError. Two practical hazards: SPF only checks the SMTP MAIL FROM (envelope sender, not the visible From header), so it does not protect against display-name spoofing; and the ten-lookup limit can easily be exceeded when chaining include: for several SaaS senders. SPF is one of the three pillars of modern email authentication together with DKIM and DMARC, where DMARC aligns the visible From header to the SPF or DKIM result.

SecDNS perspective

The SecDNS authoritative editor lints SPF records, counts your DNS lookups, and warns before you ship a v=spf1 policy that will permerror at the receivers.

Frequently asked questions

How many DNS lookups can an SPF record do?

Ten. RFC 7208 caps the number of DNS-querying mechanisms (include, a, mx, ptr, exists, redirect) at ten, after which mail receivers must treat the policy as a permanent error.

What is the difference between -all and ~all?

-all is hard fail and tells receivers to reject. ~all is soft fail and tells receivers to accept but mark. Move to -all only when you are confident every legitimate sender is covered.