Suped

SPF

What SPF is, how it works, and how the 10-lookup limit affects your email authentication.

SPF (Sender Policy Framework) specifies which mail servers are allowed to send email for your domain. Receiving servers check the SPF record to verify that incoming email comes from an authorized source.

The SPF record

An SPF record is a DNS TXT record published at yourdomain.com, starting with v=spf1.

Example:

v=spf1 include:_spf.google.com include:sendgrid.net -all

Mechanisms

MechanismPurposeExample
ip4:Allow a specific IPv4 address or rangeip4:192.0.2.1
ip6:Allow a specific IPv6 address or rangeip6:2001:db8::1
include:Include another domain's SPF recordinclude:_spf.google.com
aAllow the domain's A record IPa
mxAllow the domain's MX record IPsmx
redirect=Use another domain's SPF record entirelyredirect=otherdomain.com

Qualifiers

The record ends with an all mechanism that defines the default action for senders not explicitly listed:

  • -all - Hard fail. Reject emails from unlisted senders.
  • ~all - Soft fail. Accept but mark as suspicious.
  • ?all - Neutral. No opinion on unlisted senders.

The 10-lookup limit

Every include, a, mx, and redirect mechanism requires a DNS lookup. SPF allows a maximum of 10 lookups. Exceeding this causes a permerror, which means SPF fails for all emails.

This limit is easy to hit when you use multiple email services (Google Workspace, SendGrid, Mailchimp, etc.), since each include can trigger nested lookups. Use SPF flattening to resolve IP addresses and reduce lookup count.

SPF alignment with DMARC

DMARC checks that the Return-Path domain (the domain checked by SPF) aligns with the From header domain. If these don't match, SPF passes but DMARC alignment fails for SPF. See DMARC alignment for details.