TutorialsDecember 13, 2025 11 min read

SPF Record Setup Guide: Configure DNS for Email Auth

Learn how to set up SPF records correctly. Step-by-step DNS configuration guide with examples for Gmail, Office 365, and custom mail servers.

WizStatus Team
Author

Sender Policy Framework (SPF) is your first line of defense against email spoofing. It specifies which mail servers are authorized to send email on behalf of your domain.

When a receiving mail server gets an email from your domain, it checks your SPF record to verify authorization. Proper SPF configuration is essential for email deliverability.

SPF is one of the most commonly misconfigured email authentication mechanisms. Follow this guide carefully to avoid delivery issues.

What is SPF (Sender Policy Framework)?

SPF is an email authentication standard defined in RFC 7208. It allows domain owners to specify which IP addresses and servers can send email using their domain name.

How SPF Works

  1. You publish an SPF record as a DNS TXT record at your domain root
  2. When an email is received, the server extracts the envelope sender domain
  3. The receiving server looks up your SPF record
  4. It checks if the connecting IP matches any authorized sources
  5. The result determines how the email is handled

SPF Result Types

ResultMeaning
passIP is authorized
failIP is explicitly not authorized
softfailIP is probably not authorized
neutralDomain makes no assertion
temperrorDNS lookup issue
permerrorSyntax error in record

Why Proper SPF Configuration Matters

SPF is a mandatory component of email authentication. Its importance increased significantly with the 2024 Gmail and Yahoo requirements.

Deliverability Impact

  • Emails failing SPF are more likely to be marked as spam
  • Proper SPF demonstrates you take email security seriously
  • Major providers require SPF for bulk senders

Security Benefits

SPF provides protection against basic email spoofing attacks. While not foolproof alone, it makes it harder for attackers to impersonate your mail servers.

Misconfigured SPF records cause legitimate emails to fail authentication. Important business emails may land in spam or be rejected entirely.

Common SPF Problems

  • Exceeding the 10 DNS lookup limit
  • Forgetting to include third-party senders
  • Using deprecated mechanisms
  • Syntax errors in the record

How to Configure SPF Records

SPF configuration starts with identifying all legitimate sources that send email using your domain.

Step 1: Inventory Your Email Sources

List all systems that send email as your domain:

  • Primary mail server
  • Marketing platforms (Mailchimp, HubSpot, etc.)
  • CRM systems (Salesforce, etc.)
  • Transactional email services (SendGrid, Postmark)
  • Support ticketing systems
  • Any other third-party tools

Step 2: Understand SPF Syntax

A basic SPF record follows this structure:

v=spf1 [mechanisms] [qualifier]all

Required elements:

  • v=spf1 - Version prefix (required)
  • Mechanisms - Define authorized senders
  • all - Specifies how to handle non-matching senders

Step 3: Learn Common Mechanisms

MechanismPurposeExample
ip4:Authorize IPv4 address/rangeip4:192.0.2.0/24
ip6:Authorize IPv6 address/rangeip6:2001:db8::/32
include:Reference another domain's SPFinclude:_spf.google.com
aAuthorize domain's A record IPsa
mxAuthorize domain's MX serversmx

Step 4: Understand Qualifiers

Qualifiers are placed before mechanisms:

  • + (pass) - Default, authorize the source
  • - (fail) - Reject if matched
  • ~ (softfail) - Accept but mark suspicious
  • ? (neutral) - No assertion

Step 5: Build Your SPF Record

Example for Google Workspace only:

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

Example for Google Workspace + SendGrid:

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

Example with custom mail server:

v=spf1 ip4:192.0.2.0/24 include:_spf.google.com include:sendgrid.net -all

Common Provider Include Statements

# Google Workspace
include:_spf.google.com

# Microsoft 365
include:spf.protection.outlook.com

# SendGrid
include:sendgrid.net

# Mailchimp
include:servers.mcsv.net

# Amazon SES
include:amazonses.com

# Postmark
include:spf.mtasv.net

SPF Configuration Best Practices

Follow these practices to maintain a healthy SPF record.

Use Hard Fail (-all)

Always use -all (hard fail) once you've confirmed all legitimate senders are included:

# Recommended for production
v=spf1 include:_spf.google.com -all

# Only during initial testing
v=spf1 include:_spf.google.com ~all
Use ~all (softfail) only during initial testing. Switch to -all once verified.

Monitor DNS Lookup Count

SPF is limited to 10 DNS lookups. Each of these counts:

  • include: mechanisms
  • a mechanisms
  • mx mechanisms
  • redirect modifiers
  • Nested includes within referenced records

Check your total with online SPF validators:

# Example command to check SPF record
dig +short TXT example.com | grep spf
Exceeding 10 lookups causes a permerror, failing all SPF checks for your domain.

Keep Records Simple

  • Consolidate IP ranges using CIDR notation
  • Remove services you no longer use
  • Avoid redundant mechanisms
  • Document every entry

Use Subdomain Strategies

Consider using subdomains for different email types:

# Root domain - minimal
example.com: v=spf1 include:_spf.google.com -all

# Marketing subdomain - separate
marketing.example.com: v=spf1 include:servers.mcsv.net -all

Test Before Deploying

Always test changes before production:

  1. Use SPF validators to check syntax
  2. Verify authorized IPs are included
  3. Confirm lookup count is under 10
  4. Send test emails and check headers

Document Everything

Maintain documentation for your SPF record:

# SPF Record Documentation

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

## Included Sources
| Mechanism | Service | Added | Contact |
|-----------|---------|-------|---------|
| include:_spf.google.com | Google Workspace | 2024-01 | IT Team |
| include:sendgrid.net | SendGrid | 2024-03 | Marketing |

Conclusion

A well-configured SPF record is essential for email deliverability and security. By understanding SPF syntax, documenting your sending sources, and staying within limits, you create a solid foundation.

Remember that SPF is just one component. Combined with DKIM and DMARC, SPF helps protect your domain reputation and ensures emails reach recipients.

Regular monitoring and maintenance keep your SPF record healthy as your infrastructure evolves.

Related Articles

BIMI Implementation Guide: Display Your Logo in Inboxes
Tutorials

BIMI Implementation Guide: Display Your Logo in Inboxes

Implement BIMI to show your brand logo in email clients. Requirements, VMC certificates, and setup steps for visual email authentication.
11 min read
Cold Email Deliverability: Avoid Spam Filters in 2026
Best Practices

Cold Email Deliverability: Avoid Spam Filters in 2026

Improve cold email deliverability with proven strategies. Domain warmup, authentication, content tips, and sending practices that work.
12 min read
DKIM Configuration Tutorial: Email Signing Setup Guide
Tutorials

DKIM Configuration Tutorial: Email Signing Setup Guide

Complete DKIM setup tutorial with key generation, DNS configuration, and verification steps. Ensure email integrity with cryptographic signatures.
12 min read

Start monitoring your infrastructure today

Put these insights into practice with WizStatus monitoring.

Try WizStatus Free