SPF Generator

Build a valid SPF record from 50+ email providers with a live DNS lookup counter and validation. Stay under the 10-lookup limit before you publish.

Advertisement

Generate an SPF Record That Counts Your DNS Lookups

An SPF record tells the internet which servers are allowed to send mail using your domain. Get it right and spoofed mail from your domain gets rejected. Get it wrong — and the most common way to get it wrong is silent — and your own legitimate mail starts landing in spam or bouncing outright, for everyone, at once.

This generator builds the record from a provider list and a running DNS lookup counter that is visible at all times. Tick Google Workspace, Microsoft 365, SendGrid, Mailchimp, and the rest from a database of more than 50 email providers; add your own mail server IP addresses and CIDR ranges; pick a terminator policy; and copy a syntactically valid record with the lookup budget already accounted for. It validates as you build, grades the result, and refuses to let a broken record look finished. Everything runs in your browser — no domain is queried and no data is sent anywhere.

The 10-Lookup Limit Is the Whole Problem

RFC 7208 caps an SPF evaluation at 10 DNS lookups. Exceed it and the receiving server returns a permerror, and a permerror is not a soft failure — most receivers treat it as an SPF failure, which means your mail can be rejected or junked even though every server in your record is legitimate. Nothing warns you. The record still looks correct in a DNS query. Mail simply starts failing.

These mechanisms consume lookups: include, a, mx, ptr, and exists. These do not: ip4, ip6, and all. Crucially, the count is recursive — if you include a provider whose own record contains three further includes, you have spent four lookups, not one. That is why a record with only six visible includes can blow the budget.

MechanismLookupsNotes
ip4:203.0.113.0/240Free. Prefer these wherever you control the IPs.
ip6:2001:db8::/320Free.
include:_spf.google.com1+Plus whatever the included record itself costs.
a / a:mail.example.com1Resolves A/AAAA records.
mx1Plus an A lookup per MX host, up to 10.
ptr1Deprecated by RFC 7208. Do not use it.
exists:%{i}._spf.example.com1Macro-based; rare outside large senders.
-all / ~all0The terminator. Always required.

The counter in this tool warns at 8 and marks the record invalid above 10, because the useful moment to intervene is before you have shipped a record that fails.

Why +all Is Not a Fix

When mail starts failing, the internet is full of advice to “just use +all”. Do not. +all means any server on the internet is authorised to send mail as your domain. It does not merely disable SPF — it publishes an explicit statement that every spoofer has your permission, which is worse than having no SPF record at all. Receivers and security scanners flag it as a misconfiguration, and it hands phishing campaigns a domain with a valid SPF pass. This tool treats +all as a hard error, not a warning.

The legitimate terminators, in order of strictness:

  • -all (hard fail) — anything not listed is unauthorised. The correct end state, and what DMARC enforcement expects.
  • ~all (soft fail) — treat unlisted senders as suspicious but accept. Useful for a few weeks while you find the sending systems you forgot about.
  • ?all (neutral) — no opinion. Provides essentially no protection; only meaningful during initial discovery with DMARC in p=none and reporting switched on.

If mail is failing SPF, the answer is to find the sender and add it, or to remove it from your domain — never to widen the policy until the failure disappears.

How to Use the Generator

  1. Paste your existing record if you have one. The tool parses it back into editable mechanisms so you can see where the lookups are being spent.
  2. Select your providers. Each entry in the provider database carries its correct include and its known lookup cost, including whether it recurses.
  3. Add your own servers as ip4 or ip6. IP addresses and CIDR ranges are validated as you type, and they cost zero lookups.
  4. Add custom mechanisms where you need an a, mx, exists, or a non-default qualifier.
  5. Choose the terminator. Start at ~all if you are not yet confident you have found every sender; move to -all once DMARC reports are clean.
  6. Read the validation panel and the grade. Errors mean the record will not work. Warnings mean it will work today and is fragile.
  7. Open the optimizer if you are near the limit — it identifies which mechanisms are costing the most and what can be consolidated.
  8. Follow the deployment instructions to publish it as a TXT record at the apex of your domain.

Getting Under the Limit

When the counter is over 10, there are three real fixes and one fake one.

  • Subdomain delegation — the best answer. Move bulk and marketing senders onto their own subdomain: send campaigns from mail.example.com or news.example.com, each with its own SPF record and its own fresh 10-lookup budget. The apex record then only has to authorise your corporate mail. This also isolates your primary domain’s reputation from marketing send volume.
  • Replace includes with ip4 where you control the addresses. Your own mail relay does not need an a or mx lookup; its IP costs nothing.
  • Remove senders you no longer use. Old records accumulate includes for services cancelled years ago. Auditing DMARC reports tells you which includes are actually carrying mail.
  • SPF flattening — use with care. Third-party services expand every include into a literal IP list, reducing the count to zero lookups. It works, but the expansion is a snapshot: when your provider changes its sending infrastructure, your flattened record is silently wrong and mail fails. Only use a flattening service that re-resolves and republishes automatically, and never hand-flatten a large provider once and forget it.

One more constraint: a single DNS TXT string is limited to 255 characters. Longer records must be split into multiple strings within the same TXT record, which DNS concatenates on retrieval. This is a valid and common arrangement, but publishing two separate TXT records that both start v=spf1 is not — that is a permerror, and it is the second most common SPF fault after the lookup limit.

SPF Is One of Three

SPF authorises sending IPs. It does not survive forwarding, and it validates the envelope sender (the MAIL FROM), not the From: header the recipient actually sees. On its own it stops very little. It becomes effective as part of a set:

  • DKIM cryptographically signs the message, so it survives forwarding and proves the content was not altered.
  • DMARC ties SPF and DKIM to the visible From: domain through alignment, tells receivers what to do on failure, and — most usefully — sends you reports showing who is sending as your domain. Build one with the DMARC record generator.

The sequence that works: publish SPF with ~all, enable DKIM signing, publish DMARC at p=none with a reporting address, read the reports for a few weeks until every legitimate sender is accounted for, then tighten to -all and p=quarantine or p=reject. Check the finished configuration with the email authentication validator, and confirm what is actually published using the DNS lookup tool.

Frequently Asked Questions

What happens if my SPF record exceeds 10 DNS lookups?

Receivers return a permerror. Under DMARC that counts as an SPF failure, so depending on your DMARC policy your mail can be quarantined or rejected — including mail from servers you correctly listed. There is no partial credit and no warning; the record simply stops working.

Can I have two SPF records on one domain?

No. Exactly one TXT record beginning v=spf1 is permitted per domain. Two is a permerror. If you need to authorise more senders, merge the mechanisms into a single record — or better, delegate some senders to a subdomain.

Should I use -all or ~all?

-all is the correct destination. Use ~all only as a temporary state while you verify, through DMARC reports, that every legitimate sender is listed. Leaving ~all in place permanently means unauthorised mail is accepted rather than rejected.

Does SPF stop phishing?

Partially. It stops mail claiming to come from your domain’s envelope sender from unauthorised IPs. It does not stop lookalike domains, display-name spoofing, or compromised accounts sending from an authorised server. SPF plus DKIM plus an enforcing DMARC policy is the combination that meaningfully reduces domain spoofing.

Why is my mail failing SPF after being forwarded?

Because forwarding changes the sending IP without changing the envelope sender, so SPF fails by design. DKIM signatures survive forwarding, which is why DMARC accepts a pass from either mechanism. This is the main reason SPF alone is insufficient.

Is SPF flattening safe?

Only when it is automated. Flattening freezes your provider’s current IP ranges into your record; when they change infrastructure, your record becomes wrong and mail fails silently. If you flatten, use a service that re-resolves and republishes on a schedule, and monitor it.

Does the tool query my domain or send my data anywhere?

No. Record generation, lookup counting, and validation all run in JavaScript in your browser. Provider lookup costs come from a bundled database, not from live DNS queries, so nothing about your domain is transmitted.

Where do I publish the record?

As a TXT record at the root of your domain — host @ or the domain name itself, depending on your DNS provider’s interface. Set a low TTL such as 300 seconds while you are testing so mistakes can be corrected quickly, then raise it once the record is stable. Verify it resolves before assuming it is live.

What Is SPF (Sender Policy Framework)

SPF (Sender Policy Framework) is an email authentication protocol that allows domain owners to specify which mail servers are authorized to send email on behalf of their domain. Published as a DNS TXT record, SPF helps receiving mail servers distinguish legitimate messages from spoofed ones—making it a critical defense against email spoofing, phishing, and business email compromise.

Without SPF, any server in the world can claim to send email from your domain, and the receiving server has no way to verify the claim. SPF addresses this by creating a publicly queryable list of authorized sending sources. When configured alongside DKIM and DMARC, SPF forms part of the email authentication triad that protects organizations from domain impersonation.

How SPF Works

An SPF record is a DNS TXT record published at the domain's root. When a mail server receives a message, it extracts the sender's domain from the MAIL FROM (envelope sender) and queries DNS for the SPF record. It then evaluates the sending server's IP address against the authorized sources listed in the record.

SPF record syntax:

MechanismMeaningExample
ip4:Authorize an IPv4 address or rangeip4:203.0.113.0/24
ip6:Authorize an IPv6 address or rangeip6:2001:db8::/32
aAuthorize the domain's A record IPsa
mxAuthorize the domain's MX record IPsmx
include:Include another domain's SPF recordinclude:_spf.google.com
redirect=Use another domain's SPF record entirelyredirect=_spf.example.com
allCatch-all for non-matching IPs-all (hard fail)

Qualifier prefixes:

  • + (pass) — Default; IP is authorized
  • - (hard fail) — IP is NOT authorized; reject the message
  • ~ (soft fail) — IP is NOT authorized; accept but flag
  • ? (neutral) — No policy assertion

Example SPF record:

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

This authorizes: one specific IP, Google Workspace servers, SendGrid servers, and hard-fails everything else.

Common Use Cases

  • Email security: Prevent attackers from spoofing your domain in phishing emails sent to customers and partners
  • Email deliverability: Properly configured SPF reduces the chance of legitimate emails being marked as spam
  • Compliance: Standards like NIST 800-177 and CMMC require SPF as part of email security controls
  • Vendor onboarding: Verify that third-party services (CRM, marketing, support) are included in your SPF record before they send on your behalf
  • Domain reputation management: SPF failures contribute to poor domain reputation scores at major email providers

Best Practices

  1. Always end with -all (hard fail) — This tells receivers to reject unauthorized senders; ~all (soft fail) is weaker and should only be used during initial deployment
  2. Stay under 10 DNS lookups — SPF is limited to 10 DNS lookups; use ip4/ip6 mechanisms instead of nested includes where possible
  3. Include all legitimate senders — Missing a third-party sender (marketing platform, ticketing system) causes their emails to fail SPF
  4. Flatten SPF records if needed — Use SPF flattening tools to resolve includes into IP addresses, reducing DNS lookup count
  5. Combine with DKIM and DMARC — SPF alone is incomplete; DKIM prevents message tampering and DMARC provides policy enforcement and reporting

Frequently Asked Questions

What is an SPF record?+

Sender Policy Framework (SPF) is DNS TXT record listing authorized mail servers for your domain. Format: v=spf1 ip4:192.0.2.0 include:_spf.google.com ~all. Recipient mail servers check if sending IP matches SPF record. Prevents email spoofing by validating sender. Mechanisms: ip4/ip6 (IP addresses/ranges), include (third-party SPF), a/mx (domain A/MX records), all (default policy). Essential email authentication with DKIM/DMARC.

How to create an SPF record?+

List all mail servers sending from your domain: your mail server IPs, email service providers (Google, Microsoft), marketing tools (Mailchimp, SendGrid). Format: v=spf1 [mechanisms] [qualifier]all. Example: v=spf1 ip4:192.0.2.0/24 include:_spf.google.com include:spf.protection.outlook.com ~all. Add TXT record at root domain. Test: send email, check headers for SPF pass. Limit: 10 DNS lookups max. Use include: for third parties, not nested includes.

What do SPF qualifiers mean?+

SPF qualifiers define handling for matching mechanisms. Four types: + (pass) - explicitly allowed, default if omitted. - (fail) - hard fail, reject email. ~ (softfail) - accept but mark suspicious. ? (neutral) - no policy. Example: v=spf1 ip4:192.0.2.0 ~all (allow IP, soft fail others). Recommendation: use ~all (softfail) initially, upgrade to -all (hard fail) after testing. Too strict -all causes false positives from forwarding.

What is the SPF 10 lookup limit?+

SPF RFC limits DNS lookups to 10 to prevent DoS attacks. Mechanisms requiring lookups: include, a, mx, ptr (avoid ptr), exists. Does not count: ip4, ip6, all. Exceeding limit causes SPF permanent error (treated as no SPF). Solutions: flatten SPF (replace includes with IPs), use SPF flattening services, remove unnecessary includes, consolidate third-party senders. Monitor: SPF record size (<450 chars recommended), lookup count.

How to include third-party senders?+

Use include: mechanism for third-party email services. Example: include:_spf.google.com for Google Workspace, include:spf.protection.outlook.com for Microsoft 365, include:servers.mcsv.net for Mailchimp. Each include counts toward 10 lookup limit. Order does not matter for includes. Verify: third party provides SPF include record. Multiple includes allowed. Test after adding: dig TXT domain.com, check SPF syntax, send test emails.

What happens if SPF fails?+

SPF failure means sending IP not authorized in SPF record. Result depends on: SPF qualifier (-all vs ~all), DMARC policy (none/quarantine/reject), receiving server policy. Outcomes: email rejected (DMARC p=reject), marked spam (p=quarantine), delivered with warning (~all). Legitimate failures: forwarding (breaks SPF, but DKIM survives), misconfigured SPF, missing include. Fix: update SPF record, configure forwarding (SRS), implement DKIM.

Should I use -all or ~all?+

Start with ~all (softfail) for testing - accepts email but marks suspicious. Allows identifying legitimate senders missing from SPF. After 2-4 weeks monitoring: no false positives? Upgrade to -all (hard fail) for stronger protection. Use -all only if: confident SPF is complete, DKIM configured (survives forwarding), monitoring DMARC reports. Email forwarding breaks SPF - ~all prevents false positives. Modern approach: -all with DMARC alignment.

How to handle email forwarding with SPF?+

Forwarding breaks SPF - forwarded email sent from different IP than SPF authorizes. Solutions: 1) SRS (Sender Rewriting Scheme) - rewrites envelope sender to forwarder domain. 2) DKIM - survives forwarding, provides authentication. 3) Use ~all instead of -all in SPF. 4) Configure forwarders to use SRS. Best: implement SPF, DKIM, and DMARC. DMARC requires only one (SPF or DKIM) to pass. DKIM alignment handles forwarding.

This tool is provided for informational and educational purposes only. All processing happens in your browser — no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results.