February 4, 2026 10 min read

What Is SPF and How Do I Set It Up?

SPF (Sender Policy Framework) is an email authentication protocol that tells receiving mail servers which IP addresses are authorized to send email on behalf of your domain. You set it up by publishing a TXT record in your domain's DNS that lists your authorized sending servers. Without SPF, mailbox providers cannot verify that messages claiming to be from your domain are legitimate.

Email authentication starts with SPF. When Gmail, Yahoo, or Outlook receives an email claiming to be from your domain, the first thing they check is whether the sending server is authorized. SPF provides that authorization list.

We help organizations implement SPF correctly every day, and we consistently see the same issues. This guide covers what SPF actually does, how to build a proper record, and how to avoid the mistakes that cause authentication failures.

How SPF Works

When a receiving mail server gets a message, it looks at two pieces of information: the domain in the Return-Path (envelope sender) and the IP address of the server that delivered the message. SPF verification compares the sending IP against the list of authorized IPs published in the sending domain's DNS.

The process follows these steps:

  1. Receiving server extracts the domain from the Return-Path header
  2. Server queries DNS for the TXT record containing the SPF policy
  3. Server checks if the sending IP matches any authorized source in the record
  4. Server returns a result: pass, fail, softfail, neutral, or permerror

Only a "pass" result confirms that the sender is authorized. Any other result indicates a potential problem with either the message's legitimacy or your SPF configuration.

SPF Record Syntax

An SPF record is a TXT record published at your domain's root. Every SPF record starts with a version declaration and ends with a default policy for unlisted senders.

Basic Structure

v=spf1 [mechanisms] [qualifier]all

The v=spf1 prefix identifies this as an SPF record (version 1 is the only version). The mechanisms in the middle define authorized senders. The all at the end specifies what happens when a sender does not match any mechanism.

Common Mechanisms

Qualifiers

Building Your SPF Record

Creating an effective SPF record requires identifying all legitimate sources that send email using your domain.

Step 1: Inventory Your Sending Sources

List every system that sends email as your domain:

Step 2: Gather SPF Include Statements

Each third-party service provides an include statement for their sending infrastructure. Common examples:

include:_spf.google.com       (Google Workspace)
include:amazonses.com         (Amazon SES)
include:spf.protection.outlook.com  (Microsoft 365)

Check your email provider's documentation for their specific SPF include requirement.

Step 3: Construct the Record

Combine your findings into a single record:

v=spf1 ip4:203.0.113.5 include:_spf.google.com include:amazonses.com -all

This record authorizes:

The -all at the end instructs receivers to reject mail from any other source.

The 10 DNS Lookup Limit

SPF has a hard limit of 10 DNS lookups per evaluation. This limit exists to prevent denial-of-service attacks and excessive DNS traffic. Each of these mechanisms counts as one lookup:

The ip4: and ip6: mechanisms do not count against this limit because they do not require DNS lookups.

Include Statements Count Recursively

When you use an include statement, any lookups within that included record also count toward your limit. A single include to a service with 3 nested lookups consumes 4 of your 10 allowed lookups.

Staying Under the Limit

When you need to authorize many services:

Publishing Your SPF Record

SPF records are published as TXT records in DNS at your domain's root (apex).

DNS Record Details

Only One SPF Record Per Domain

A domain must have exactly one SPF record. If you have multiple TXT records containing SPF policies, the lookup returns a permerror and SPF fails entirely. When adding sending sources, modify your existing record rather than creating a new one.

Validating Your SPF Record

After publishing, verify your record works correctly:

  1. Use MXToolbox or similar tools to check your SPF record syntax
  2. Verify the lookup count stays under 10
  3. Send test emails and examine the Authentication-Results header
  4. Check for SPF alignment if you are using DMARC

Look for spf=pass in email headers to confirm proper configuration.

Common SPF Mistakes

Forgetting a Sending Source

The most common issue we see is incomplete SPF records. Marketing adds a new email tool, IT is not informed, and suddenly campaign emails fail SPF. Maintain a central inventory of all email-sending systems and update SPF when anything changes.

Using +all Instead of -all

Never end your SPF record with +all. This authorizes the entire internet to send as your domain, completely defeating the purpose of SPF. Use -all (hard fail) or at minimum ~all (soft fail).

Exceeding the Lookup Limit

Adding too many include statements breaks SPF entirely. Before adding a new service, check your current lookup count. If you are at or near 10, you need to restructure before adding more sources.

Syntax Errors

Missing spaces, typos in mechanism names, or incorrect IP notation cause SPF to fail with a permerror. Always validate your record with an SPF checker before publishing.

SPF and DMARC Alignment

SPF alone verifies the envelope sender (Return-Path), but recipients see the header From address. DMARC requires alignment between these addresses for SPF to contribute to a passing DMARC result.

SPF alignment means the domain in the Return-Path must match (or be a subdomain of) the domain in the visible From header. Without alignment, SPF can pass but DMARC may still fail.

For bulk senders, Gmail and Yahoo require DMARC compliance, which means your SPF must both pass and align correctly.

Frequently Asked Questions

What does SPF stand for?
SPF stands for Sender Policy Framework. It is an email authentication protocol that allows domain owners to specify which mail servers are authorized to send email on behalf of their domain.
Where do I add my SPF record?
SPF records are added to your domain's DNS as a TXT record. You add them through your domain registrar or DNS hosting provider's control panel. The record goes at the root of your domain (often represented as @ in DNS interfaces).
Can I have multiple SPF records?
No, you should only have one SPF record per domain. Multiple SPF records cause authentication failures with a permerror result. If you need to authorize multiple sending sources, combine them all into a single SPF record.
What is the SPF 10 DNS lookup limit?
SPF allows a maximum of 10 DNS lookups when evaluating your record. Each include, a, mx, ptr, and redirect mechanism counts as a lookup. Exceeding this limit causes SPF to fail with a permerror result, so you must carefully manage how many services you include.

Ready to Improve Your Email Deliverability?

SortedIQ helps high-volume senders maximize inbox placement and sender reputation.

Talk to Our Team