What Is an SPF Record? Setup, Examples, and Common Errors

By Dave TanguayPublished Editorial draft

Quick Answer

An SPF record is a DNS TXT record that lists the servers allowed to send email for a domain used in the message’s envelope sender. Receiving mail systems compare the sending server with that policy. Publish one SPF policy at each relevant DNS name, include every legitimate sender, and check the result on real messages. SPF helps authenticate mail, but a passing result does not guarantee inbox placement or prove that the visible From address belongs to the sender.

A business can send email from employee mailboxes, a website form, an online store, a newsletter platform, and an invoicing service. Adding SPF for the mailbox provider does not automatically configure the other systems. The work starts by finding out which services send which messages.

Our business email authentication guide explains how SPF works with DKIM and DMARC. This guide covers the SPF record itself and how to investigate a failing check.

What SPF checks

SPF stands for Sender Policy Framework. For a normal message, it checks the connecting server’s IP address against the policy for the domain in SMTP MAIL FROM, also called the envelope sender. That address handles delivery failures and often appears as the Return-Path after delivery. It can differ from the From address your customer sees. Mail with an empty envelope sender uses the SMTP HELO identity for SPF instead.

For example, a message might display sales@example.com while using an envelope sender under bounce.example.net. Checking only the TXT records for example.com would not tell you how that message’s envelope domain authenticates. Amazon SES documents this distinction in its SPF and custom MAIL FROM explanation.

MX records control where a domain receives mail. SPF identifies permitted outbound sending sources. Changing MX records is not a general solution to an SPF problem. A business can receive mail at one provider and use several other services to send messages.

Read an SPF record

The following record is a teaching example using reserved addresses and domains. It is not a working policy to copy into your DNS:

Type: TXT
Name: example.com
Value: v=spf1 ip4:192.0.2.20 include:_spf.sender.example.net ~all
Parts of the example SPF policy
Part Meaning
v=spf1 Identifies the TXT value as an SPF version 1 policy.
ip4:192.0.2.20 Authorizes that illustrative IPv4 address. An ip6: mechanism can authorize an IPv6 address or network.
include:_spf.sender.example.net Evaluates another domain’s SPF policy. A passing result there can authorize the sender here.
~all Produces softfail for sending addresses that reach this mechanism without an earlier match.

Mechanisms are evaluated in order. An all mechanism matches every address that reaches it, so mechanisms after it cannot authorize another sender. An omitted qualifier means pass for a matching mechanism. The qualifiers -, ~, and ? request fail, softfail, and neutral results respectively. Cloudflare’s SPF record explanation introduces the policy syntax.

redirect= delegates evaluation to another domain’s policy when the current record has no matching mechanism. It has a different purpose from adding another provider with include:. Avoid combining mechanisms or modifiers you do not understand to silence a checker.

Include multiple sending services

A DNS name must not publish two separate SPF policies. If both your mailbox provider and newsletter platform ask for SPF, their requirements must be reconciled into one valid policy for the same name. Other unrelated TXT records, such as site-verification records, can remain.

Do not replace the existing policy with a new provider’s suggested line without checking what the old policy authorized. That can repair one sending route while breaking employee messages, receipts, or invoices. Google’s SPF setup instructions distinguish a Google-only policy from a policy involving other senders.

Separate envelope-sender subdomains can have separate policies when the sending architecture calls for them. SPF at example.com does not automatically establish SPF at mail.example.com. Ask the provider which envelope domain it actually uses before deciding where a record belongs.

Understand the DNS lookup limit

The SPF standard, RFC 7208, limits evaluation to 10 DNS-query-causing terms. These include include, a, mx, ptr, exists, and redirect, including terms reached recursively. Exceeding the limit produces permerror. Literal ip4, ip6, and all mechanisms do not consume that allowance. Other limits also apply.

This is not a limit of 10 email platforms or 10 TXT records. An include can lead to several more includes, and the evaluated path matters. Check the expanded policy with a suitable SPF validator instead of counting the visible include: strings. Google’s SPF troubleshooting guidance covers nested lookups and identifying obsolete senders.

Keep an inventory before removing anything. A sender that runs only at month-end may look unused during a short review. Remove obsolete authorization after its owner confirms retirement. Replacing provider includes with copied IP lists creates a maintenance obligation when those providers change their infrastructure; it should not be an automatic response to a lookup warning.

Set up or correct SPF

  1. Identify the actual sender. Record the system, message purpose, visible From domain, and envelope domain. Include infrequent and automated sending jobs.
  2. Find the authoritative DNS service. The website host and domain registrar may not host the active zone. Editing a non-authoritative copy does not update public DNS.
  3. Preserve the before-state. Save the current TXT values and the sending-provider instructions. Assign an owner for the change and a recovery path.
  4. Reconcile the policy. Combine the requirements that belong at the same DNS name. Check syntax, authorized sources, ordering, and recursive lookup behavior.
  5. Choose the ending deliberately. ~all and -all produce different failure signals. Follow the sending architecture and provider guidance rather than changing this character as a generic spam-folder fix.
  6. Make the scoped DNS change. Preserve unrelated TXT and MX records. Some DNS interfaces expect @ for the root name; others expect a full name or append the zone automatically.
  7. Verify every sending route. Check DNS and new received messages. Keep the before-state until the intended routes and any affected applications have been checked.

When DNS is at Cloudflare and mail is on cPanel, the relevant public TXT record belongs in Cloudflare’s authoritative zone. Our cPanel and Cloudflare authentication guide covers that split. Moving nameservers is a separate task from adding a sender.

Verify DNS and a received message

Start with a read-only lookup for the actual envelope domain. For a teaching example, Windows PowerShell can query Resolve-DnsName -Name example.com -Type TXT; systems with dig can query dig TXT example.com. Substitute the domain being investigated. These illustrative commands have not been run against your domain.

A lookup establishes what that resolver returned at that time. Compare with the authoritative nameservers when results disagree, and account for cached records. Avoid repeatedly editing values while older answers are still being cached.

Next, send an authorized test through the relevant application or mailbox. Inspect the destination provider’s full-message authentication details. A useful record captures the receiving system, time, SPF result, evaluated envelope domain, and sending IP. Trust authentication results supplied by the receiving system rather than arbitrary header text copied into a message by its sender.

Repeat the check for each route. A message sent from a staff mailbox cannot establish that the website form uses the same service. For missing inquiries, the website-form delivery checklist also traces submission and application handoff.

Interpret SPF results

Scroll horizontally to see all columns.

SPF result and useful next investigation
Result Meaning Next check
pass The policy authorizes the sending server. Check alignment and the other delivery signals.
fail The policy says this server is unauthorized. Identify the route before changing authorization.
softfail The policy gives a weaker unauthorized signal. Compare the source with the legitimate-sender inventory.
neutral The policy makes no authorization assertion. Review the matching mechanism and intended policy.
none No applicable SPF policy was found. Confirm the evaluated name and published policy.
temperror A temporary evaluation problem occurred. Investigate DNS/service availability and retry evidence.
permerror The policy cannot be evaluated correctly. Check duplicate policies, syntax, and lookup limits.

These are authentication results. The receiving provider decides whether to accept, defer, reject, or filter the message using its own rules and other evidence.

Forwarding and DMARC alignment

A forwarder may deliver the message from a different IP address while retaining the original envelope domain. That can break SPF even though the original sender was authorized. A forwarding service may rewrite the envelope sender, but that change does not automatically preserve alignment with the visible From domain.

DKIM signatures and DMARC alignment help explain the rest of the result. SPF can pass for a service-owned envelope domain while DMARC fails because that domain does not align with the visible From address and no aligned DKIM signature passes.

Key Takeaways

  • Check the message’s envelope domain before deciding which SPF policy matters.
  • Reconcile multiple senders into one policy at the relevant DNS name.
  • Validate recursive lookup behavior and test actual messages from every route.
  • Use SPF together with DKIM and DMARC, and investigate delivery separately.

Frequently Asked Questions

Can I have two SPF records?

Not two SPF policies at the same DNS name. Combine the legitimate sender requirements into one valid policy. A separate sending subdomain can have its own policy when that is the provider’s required setup.

Does every TXT record count toward SPF’s lookup limit?

No. The limit concerns DNS-query-causing SPF terms encountered during evaluation, including recursive evaluation. Counting the zone’s TXT records or visible providers does not measure it correctly.

Does Cloudflare send my mail when it hosts my SPF record?

Hosting the DNS record does not make Cloudflare your outbound mail service. Publish the values required by the systems that actually send your messages.

Should I change softfail to fail to stop spam?

Review the legitimate sending routes and policy purpose first. That character changes the SPF result for unmatched servers; it does not repair other authentication, alignment, or reputation problems.

Why does SPF pass but my email still go to spam?

The pass authenticates one part of the sending identity. The receiver also evaluates other signals. Use our business email spam troubleshooting guide to separate authentication from placement.

For a website or hosting-related sending problem, contact Interactive Online with the affected sending route, approximate time, and non-sensitive error details. Our cPanel hosting information explains the available hosting scope.

Archives