Documentation

Learn how to integrate and use DDMARC

10 minutesEssential

SPF Setup Guide

Learn how to configure SPF records to authorize legitimate email senders and prevent spoofing.

What is SPF?

SPF (Sender Policy Framework) is a DNS-based email authentication method that allows domain owners to specify which mail servers are authorized to send email on behalf of their domain. When an email is received, the receiving server checks the SPF record to verify that the sending server is authorized.

SPF Record Syntax

An SPF record is a TXT record published at your domain. Here is an example of a complete SPF record:

Example SPF Record
v=spf1 include:_spf.google.com include:sendgrid.net ip4:192.168.1.1 -all
MechanismDescriptionExample
ip4Authorize IPv4 addressesip4:192.168.1.1
ip6Authorize IPv6 addressesip6:2001:db8::1
aAuthorize domain's A record IPsa:mail.example.com
mxAuthorize domain's MX record IPsmx
includeInclude another domain's SPFinclude:_spf.google.com
allMatch all (used at end)-all

SPF Qualifiers

Each mechanism can be prefixed with a qualifier that determines what action to take when matched:

+

Pass

Allow the email (default if no qualifier)

-

Fail

Reject the email (hard fail)

~

SoftFail

Accept but mark as suspicious

?

Neutral

No assertion about authorization

Common Email Providers

Here are the SPF include statements for popular email providers:

ProviderSPF Include
Google Workspace
include:_spf.google.com
Microsoft 365
include:spf.protection.outlook.com
Amazon SES
include:amazonses.com
Mailchimp
include:servers.mcsv.net
SendGrid
include:sendgrid.net
Mailgun
include:mailgun.org

Step-by-Step Setup

1

Identify all sending sources

List all services that send email on your behalf (your mail server, marketing tools, CRM, etc.).

2

Gather SPF includes

Get the SPF include statement from each provider. Check their documentation or support.

3

Build your SPF record

Combine all includes into a single record starting with v=spf1 and ending with -all.

4

Publish to DNS

Add the TXT record to your domain's DNS. The record goes at your root domain (not a subdomain).

5

Test and verify

Use SPF validation tools to verify your record is correct and all senders are authorized.

SPF Lookup Limit

SPF records are limited to 10 DNS lookups. Each include, a, mx, and redirect mechanism counts as one lookup. Nested includes also count toward this limit.

  • Use ip4 and ip6 when possible (no lookup required)
  • Consider SPF flattening services for complex setups

Best Practices

  • Always end your SPF record with -all for strict enforcement
  • Have only one SPF record per domain (multiple records will fail)
  • Keep the record under 255 characters if possible
  • Review and update your SPF record when adding new email services

Next Steps