Octeth v6.0.9 Now Available! See What's New
Free Generator Tool

SPF Record Generator

Create an SPF record for your domain

Pick your email providers, add your own sending servers, and watch the DNS lookup count as you build the record. A correct SPF record stops spoofing of your domain and improves deliverability.

Cem Hurturk

Cem Hurturk, Founder of Octeth

Enter your domain without http:// or www

Authorize your MX servers to send email

Authorize your domain's A record IP

Separate multiple addresses with commas. Supports CIDR notation (e.g., 192.168.1.0/24)

Separate multiple addresses with commas. Supports CIDR notation

Separate multiple domains with commas, or click a provider below to add its include.

DNS lookups in this record 2 / 10

Counts include, a, mx, ptr, exists and redirect. Lookups inside each included record also count toward the limit of 10, so the real total is usually higher than this number. Check the published record with the SPF validator.

Tip: Start with "SoftFail" (~all) to monitor, then switch to "Fail" (-all) after verifying all legitimate senders are included.

Understanding SPF Records and Their Importance

What is an SPF Record?

SPF (Sender Policy Framework) records are DNS TXT records that specify which mail servers are authorized to send emails on behalf of your domain. By defining these authorized servers, SPF records help prevent email spoofing, where attackers send emails that appear to come from your domain, and significantly improve the deliverability of your legitimate emails.

SPF Mechanism Reference

a

Authorize your domain's A record IP address

mx

Authorize your domain's MX record servers

ip4:address

Authorize a specific IPv4 address or range

ip6:address

Authorize a specific IPv6 address or range

include:domain

Include another domain's SPF record

-all / ~all

Fail or SoftFail unauthorized senders

How to Create an SPF Record

1

List every service that sends mail as your domain

Include your mailbox provider (Google Workspace, Microsoft 365), your email marketing platform, your help desk and billing tools, and any server you run yourself. A sender you leave out will fail SPF.

2

Find the include or IP for each sender

Hosted services publish an include, such as include:_spf.google.com. Pick it from the presets above or copy it from the service's setup guide. For your own servers, enter their public IPv4 and IPv6 addresses.

3

Check the DNS lookup counter

Every include, a and mx costs at least one of the 10 lookups SPF allows. Keep the counter under 10. If you are close, replace a and mx with the exact ip4 addresses.

4

Choose the all qualifier and generate

Start with ~all (SoftFail) while you confirm the sender list, then move to -all if you want a strict policy. Click Generate SPF Record and copy the result.

5

Publish it as one TXT record and test it

In your DNS provider, add a TXT record with host @ (the root domain) and the record as its value. If a v=spf1 record already exists, edit it instead of adding a second one. After the TTL passes, check it with the SPF validator.

Worked Example

A company uses Google Workspace for staff mail, Mailgun for receipts, and its own server at 203.0.113.10 for newsletters. It has no SPF record yet. The steps above give this record:

v=spf1 ip4:203.0.113.10 include:_spf.google.com include:mailgun.org ~all
  • ip4:203.0.113.10 authorizes the newsletter server. It costs no DNS lookup.
  • include:_spf.google.com authorizes Google Workspace. It uses 1 lookup, because Google's record lists only IP ranges.
  • include:mailgun.org authorizes Mailgun. It uses 5 lookups, because Mailgun's record includes four more records.
  • ~all soft-fails every other server.

The total is 6 lookups, under the limit of 10. Providers change their records, so check the count again when you add a sender. The company publishes it as a single TXT record on the root domain.

SPF Record Examples

Common records you can copy and adapt. Replace the example IP address with your own.

Google Workspace only

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

Authorizes Google's mail servers and soft-fails everything else. This is the record Google documents for Workspace domains. It uses 1 DNS lookup plus any lookups inside Google's record.

Microsoft 365 only

v=spf1 include:spf.protection.outlook.com -all

Authorizes Exchange Online and hard-fails everything else. This is the record Microsoft documents for Microsoft 365 domains. Switch to ~all if other services still send for the domain.

Google Workspace plus a self-hosted sending server

v=spf1 ip4:203.0.113.10 include:_spf.google.com ~all

Staff mail goes through Google. Marketing mail goes out from your own server at 203.0.113.10. The ip4 mechanism needs no DNS lookup, so the server costs nothing against the 10 lookup limit.

SPF Rules That Break Records

The 10 DNS Lookup Limit

RFC 7208 allows at most 10 DNS lookups while a receiver evaluates your SPF record. The include, a, mx, ptr and exists mechanisms and the redirect modifier each use one. Every include also pulls in the lookups of the record it points to, so a record with four includes can pass the limit on its own. Past 10, the check returns a permanent error and SPF fails. To stay under it, remove services that no longer send for you, drop ptr, and list your own servers with ip4 and ip6, which use no lookups.

~all vs -all

~all (SoftFail) tells receivers that mail from unlisted servers is probably not authorized. It is usually accepted and marked as suspicious. -all (Fail) says unlisted servers are not authorized, and some receivers reject that mail outright. Start with ~all until you have confirmed every sender, then move to -all if you want the stricter policy. With a DMARC policy of quarantine or reject in place, DMARC controls what happens to failing mail, so ~all is a common choice. Never publish +all, which authorizes every server on the internet.

One SPF Record per Domain

A domain can publish only one TXT record that starts with v=spf1. Two SPF records cause a permanent error, and receivers then treat SPF as failed for all your mail. This often happens when a new service tells you to "add this SPF record" and the old one stays in place. Merge the new include into your existing record instead. Subdomains are separate: mail.example.com can have its own record.

Records Longer Than 255 Characters

A single string inside a DNS TXT record holds at most 255 characters. A longer SPF record must be published as several quoted strings in the same TXT record. Receivers join the strings without adding spaces, so keep the space between mechanisms at the end of one string or the start of the next. The DNS record splitter formats long records for you. A record that long often also exceeds the 10 lookup limit, so check that too.

SPF for a Self-Hosted Sending Server

If you run your own mail server or MTA, add its public IP addresses with ip4 and ip6 rather than a or mx. This is exact and costs no lookups. SPF checks the envelope sender domain (the Return-Path), so publish the record on the domain your server uses there. Set reverse DNS on each sending IP to a hostname that resolves back to the same IP. For choosing the software and the server, see our guides to self-hosted email marketing software and VPS providers for email marketing.

Frequently asked questions

What is an SPF record?

An SPF record is a DNS TXT record that starts with v=spf1 and lists the servers allowed to send email for a domain. Receiving servers compare the connecting IP address with that list and treat mail from unlisted servers according to the all qualifier at the end of the record.

How many DNS lookups can an SPF record have?

Ten. RFC 7208 limits SPF evaluation to 10 DNS lookups. The include, a, mx, ptr and exists mechanisms and the redirect modifier each count as one, and the lookups inside every included record count too. The ip4, ip6 and all mechanisms do not count. If the limit is exceeded, the check returns a permanent error and the receiver treats SPF as failed.

Should I use ~all or -all?

Use ~all (SoftFail) while you confirm that every service that sends for your domain is in the record. Once you are sure the list is complete, you can switch to -all (Fail). If you publish a DMARC policy, DMARC decides what happens to mail that fails, so many domains keep ~all and enforce through DMARC.

Can a domain have more than one SPF record?

No. A domain must publish exactly one TXT record that starts with v=spf1. If there are two, the SPF check returns a permanent error. To add a new sender, merge its mechanisms into the existing record.

Which address does SPF check?

SPF checks the domain in the envelope sender (the MAIL FROM or Return-Path address), not the From address the reader sees. When an email service uses its own bounce domain, its SPF record covers that domain. DMARC then requires that domain to align with your From domain for SPF to count toward DMARC.

How long does a new SPF record take to work?

Receivers see the new record once their cached copy of the old one expires, which depends on the TTL set on the record. With a short TTL this is minutes. With a long TTL or a slow DNS provider it can take up to 48 hours.

Where do I add the SPF record?

In the DNS settings at your domain registrar or DNS host, such as Cloudflare, GoDaddy or Route 53. Add a TXT record, set the host or name to @ for the root domain (or the subdomain name for a subdomain), and paste the record as the value. If a v=spf1 record already exists, edit that record instead of adding a new one.

Do I still need SPF if I use DKIM and DMARC?

Yes. DMARC passes when SPF or DKIM passes and aligns with the From domain, so SPF is a second path to a DMARC pass if a DKIM signature breaks in transit. Gmail and Yahoo also require bulk senders to publish both SPF and DKIM.

Need Enterprise Email Infrastructure?

Octeth provides self-hosted email marketing software with built-in deliverability tools. Own your infrastructure and save on SaaS fees.