Skip to content
LookupOwl

SPF flattener and lookup fixer

Get an SPF record under the limit of 10 DNS lookups, with the safest fixes first and the new records ready to publish.

The domain whose SPF record to fix, such as example.com.

More options

One name per line: names we must not flatten, for example a provider that changes its addresses often.

9 leaves one spare, so adding a sender later doesn't break the record.

Paste a v=spf1 record to fix that one instead of the one published for the domain.

Results for mediawiki.org

Checked live lookup119 ms

JSONCheck again

SPF lookups

Nothing to fix. 3 of 10, 7 spare.

Want a different target? Change "Lookups to aim for" and check again.

3 of 10

Where the lookups go

3 lookups. The limit is 10. Tick: your target, 9. Biggest costs: wikimedia.org 3.

  • wikimedia.orgNo history yet3 lookups
    • _cidrs.wikimedia.orgNo history yet1 lookup
    • _spf.google.comGoogle WorkspaceNo history yet1 lookup
Structured result (JSON) · 1.5 KB
{
  "domain": "mediawiki.org",
  "source": "published",
  "permalink": "/spf-flattener?domain=mediawiki.org",
  "state": "fine",
  "before": {
    "record": "v=spf1 include:wikimedia.org ~all",
    "bytes": 33,
    "lookups": 3,
    "limit": 10,
    "exceeded": false,
    "voidLookups": 0
  },
  "costTable": [
    {
      "name": "wikimedia.org",
      "kind": "include",
      "parent": null,
      "lookups": 3,
      "ip4": 6,
      "ip6": 8,
      "provider": null,
      "flattenable": true,
      "volatility": {
        "level": "none",
        "changes30d": 0,
        "snapshots": 0
      }
    },
    {
      "name": "_cidrs.wikimedia.org",
      "kind": "include",
      "parent": "wikimedia.org",
      "lookups": 1,
      "ip4": 1,
      "ip6": 2,
      "provider": null,
      "flattenable": true,
      "volatility": {
        "level": "none",
        "changes30d": 0,
        "snapshots": 0
      }
    },
    {
      "name": "_spf.google.com",
      "kind": "include",
      "parent": "wikimedia.org",
      "lookups": 1,
      "ip4": 4,
      "ip6": 6,
      "provider": "Google Workspace",
      "category": "corporate",
      "flattenable": true,
      "volatility": {
        "level": "none",
        "changes30d": 0,
        "snapshots": 0
      }
    }
  ],
  "suggestions": [],
  "plan": {
    "choose": [],
    "lookupsAfter": 3,
    "records": []
  },
  "flatten": {
    "records": 1,
    "bytes": 310,
    "addresses": {
      "ip4": 6,
      "ip6": 8
    },
    "tooBig": false
  },
  "noSafeFix": false,
  "issues": [],
  "warnings": []
}

Next step

The 10 lookup limit, and what counts

SPF lets a receiver make at most 10 DNS lookups while it checks one message. Every include, a, mx, ptr, exists and redirect costs one, and so does every one of those inside an include. Plain ip4 and ip6 addresses cost nothing. Go over the limit and the record returns a permanent error (RFC 7208), so receivers may treat your mail as unauthenticated.

The limit is easy to reach. A company that uses Google Workspace, a marketing tool, a help desk and a billing service can hit it with four includes, because each provider's own record has includes inside. The checker follows the whole tree and shows what each include costs, so you can see where the lookups go before you change anything.

How to fix a record

  1. Enter the domainWe read its published SPF record and every include under it. To try a change first, paste a v=spf1 record under "Try a record before you publish it" and we count that one instead.
  2. Look at the budget barThe bar shows each include as a block against the limit of 10 and a tick at your target. The default target is 9, which leaves one spare so adding a sender later does not break the record.
  3. Follow the ladderThe fixes are in order, safest first. Tick or clear Apply on a step and the plan, the count and the records are rebuilt. Without JavaScript you see the recommended plan.
  4. Publish in orderPublish any new records first, then change the root record, then check it with the SPF checker.

The fixes, in the order we offer them

FixWhat it doesRisk
Remove dead includesDrops includes that no longer have an SPF record. More than 2 empty answers is an error of its own.Safe
Drop repeats and ptrRemoves an include listed twice and the discouraged ptr term.Safe
Replace mx with addressesSwaps the mx term for the addresses of your mail servers. Saves one lookup.You must confirm the addresses are fixed
Move senders to a subdomainGives marketing senders their own record on a subdomain such as news.example.com.You must confirm, and check alignment there
Flatten includesCopies a provider's addresses into your record, so it needs no lookup.Goes stale when the provider changes

The default plan applies the safe steps, then only as many of the others as it takes to reach your target. Flattening is never in the default plan. An include that uses a macro or exists depends on the sender and can never be copied, so those are marked and left alone, and any name you list under "Keep these includes as they are" is never flattened.

Why flattening is the last resort

A flattened record is a snapshot. When a provider adds or moves a sending address, your copy is wrong until you update it, and mail from the new address can fail SPF. The ladder marks flattening as going stale, shows how much bigger the record becomes, and offers it as a plan only when it fits in 6 records. An include we have never seen change is labelled "No history yet" and is never pre-selected.

If you flatten anyway, keep a reminder to recheck. A recheck link carries the names of the includes you flattened, and the page then compares their addresses today with what your records cover and lists any that are missing. For a record you have not published yet, the same page works as a calculator.

Other checks that go with SPF

Questions people ask

What happens when SPF needs more than 10 lookups?

The receiver stops and returns a permanent error. Many treat the message as if SPF had failed, and some reject it. The error is silent for the sender, so mail simply starts failing.

Should I always flatten my SPF record?

No. Flattening works but goes stale when providers change their addresses. Remove what is dead, move marketing senders to a subdomain and ask providers for a single include first. Flatten only what is left.

Why is my target 9 and not 10?

At exactly 10 lookups the next include you add breaks the record. A target of 9 leaves a spare. You can change it under More options.

Why can some includes not be flattened?

An include that uses a macro or exists is judged per message, from the sender address, so it has no fixed list of addresses to copy. The same goes for ptr and for names that did not answer.

Does the tool change my DNS?

No. It reads your records and writes the new ones as text for you to publish. Nothing is changed for you, and a record you paste is counted but never stored or put in the page address.

How big can a flattened record be?

One TXT string holds 255 characters, and a record is split into several strings that DNS joins. Large flattened lists are split across up to 6 records here. Above that, moving senders to a subdomain is the better route.

Use it from AI, the API or the command line

Every LookupOwl tool is also a free API and an MCP tool, with no key and no account. This one is spf_optimize. Please be kind to the rate limits.

curl
curl "https://lookupowl.com/api/v1/tools/spf-optimize?q=github.com"
MCP
claude mcp add --transport http lookupowl https://lookupowl.com/mcp