← Back to Thought Leadership

Unlocking the Secrets of the SPF Record: A Comprehensive Guide

July 12, 2023·10 min read

SPF records are important for getting your email messages properly authenticated by the Sender Policy Framework. A proper setup of SPF records is an important part of establishing a good foundation for email deliverability.

Your SPF records indicate which sending email servers and IP addresses are allowed to send emails on behalf of your domain. When your email hits the receiving servers, they perform lookups against your SPF record values to see if the sending server or IP is on your list of allowed senders.

If so, the message passes SPF authentication. If not, the message fails SPF authentication and could get quarantined (placed into spam) or outright rejected.

The purpose behind this authentication process is to filter out illegitimate messages from sending servers and IPs that you did not approve.

SPF record requirements

You need an SPF record for every domain or subdomain that you actively send emails from.

SPF records do not replace the need for DKIM and DMARC records. All three work in conjunction with each other, and you need all three types of records for a complete email authentication setup.

Creating an SPF record

To create an SPF record, add a TXT-type record into your DNS records host. Log into your web-hosting or CDN console, navigate to the DNS records section, and add a new record. Before you do, you need to understand the structure of SPF tags and values.

Here is an example of a typical SPF record:

v=spf1 a mx include:_spf.google.com include:_spf.salesforce.com ~all

Let's break down the component parts:

SPF record shown as a TXT record in DNS
SPF is published as a single TXT record at your domain (example from a DNS host).

Getting SPF record values

Each of your email sending platforms should have detailed deliverability documentation that guides you on the exact include: values to add to your existing SPF records. This is the best place to search for these values. Every sending platform needs to resolve eventually to a valid SPF record, or SPF authentication will fail and cause deliverability problems.

In many cases, the platforms you send from use their own domains in the Return-Path, which bypasses the need to include them in your SPF records since the lookup occurs on their DNS. However, this creates a problem of SPF alignment, which we cover below.

Common SPF mistakes

SPF PermErrors can occur when:

  1. One domain has multiple SPF records
  2. The SPF record contains syntax errors
  3. DNS lookups exceed the allowed limit of 10

Multiple SPF records

You should never have more than one SPF record on each domain or subdomain. If you have two separate SPF records:

v=spf1 a mx include:_spf.google.com ~all
v=spf1 a mx include:mxsspf.sendpulse.com ~all

Combine them into one record:

v=spf1 a mx include:_spf.google.com include:mxsspf.sendpulse.com ~all
Illustration of multiple SPF records or SPF validation issue
Two separate SPF TXT records on the same hostname cause PermError — combine includes into one record.

This is a common pitfall because most ESP instructions say "add a TXT record," but if you already have an existing SPF record, what you really need to do is add the include: part to the existing record.

If you have no SPF records at all, receiving servers won't have a reference point for SPF evaluation. Different inboxes may treat this differently — from business as usual to outright rejecting your messages. Always define an SPF record for optimal deliverability.

SPF syntax errors

Syntax errors are straightforward: a missing required v=spf1 tag, invalid symbols, or malformed include values will cause the record to fail validation.

Excessive DNS lookups

SPF records are limited to 10 DNS lookups. It is deceptively easy to hit this limit because a single include: element can generate multiple lookups when the referenced domain has its own nested includes.

If you are exceeding the threshold, you can delete unnecessary includes or look into SPF record flattening, which converts text-based lookups to raw IP addresses and ranges that do not count against the limit. Tools like MXToolBox can help you check your current lookup count.

SPF alignment

SPF references the records of the domain in the Return-Path, not the Friendly From address. The authentication process runs through lookups on the SPF record for that domain until it either finds a match or reaches the end and fails.

When sending from third-party ESPs, the ESP's own domain is often used by default in the Return-Path — not your domain. This means SPF itself can register as a pass, but SPF alignment (checked as part of DMARC evaluation) will fail because the Return-Path domain doesn't match your From domain.

The solution is a Custom Return-Path domain. You set a specific subdomain on your own domain to be used as the Return-Path for emails sent by the ESP. This is accomplished by creating a CNAME record that points to a domain provided by the ESP, achieving SPF alignment even when using a third-party sender.

Summary

Not sure if your SPF records are configured correctly? Our comprehensive Find & Fix audit includes a full review of your email authentication stack — SPF, DKIM, and DMARC — so nothing falls through the cracks. Schedule a call →

Related articles

Need help with your email program?

Schedule a free consultation with our team.

Book a Call →