SPF (Sender Policy Framework)

SPF is a DNS-based email authentication mechanism that lets domain owners declare which mail servers are authorized to send email for their domain. Receiving servers check the SPF record and can reject messages from unauthorized sources.

How SPF Works

SPF is published as a TXT record at the domain's apex. When a mail server receives a message, it extracts the envelope sender domain (the MAIL FROM address) and queries that domain's TXT records for one starting with v=spf1. It then evaluates the mechanisms in order, checking whether the sending server's IP matches any of them.

Each mechanism can have a qualifier that determines the result:

SPF Syntax

An SPF record is a single TXT record containing a space-separated list of mechanisms. Here is a typical example:

v=spf1 include:_spf.google.com ip4:203.0.113.0/24 -all

This record authorizes Google's mail servers (via the include mechanism) and any server in the 203.0.113.0/24 range. The -all at the end means all other sources should fail.

Common mechanisms:

Common Failures

SPF Alone Is Not Enough

SPF only validates the envelope sender (the MAIL FROM domain), not the From: header that users see. An attacker can spoof the visible From address while using a different envelope sender that passes SPF. To close this gap, you need DKIM to sign the message body and DMARC to enforce alignment between the visible From domain and the domains authenticated by SPF and DKIM.

Check SPF records for your domain

Open DNS Lookup

Validate your SPF record with the DNS tool →