[ SPF ]

SPF TXT strings and DNS record-length limits

Handle long SPF text as one TXT record with multiple strings, while checking DNS response size and evaluation complexity separately.

By the EmailAuth research team

On this page

A DNS editor reporting a 255-character limit does not necessarily mean your SPF policy must become multiple records. The DNS TXT format allows multiple character-strings inside one resource record. SPF treats their contents as one continuous value. The operational challenge is to preserve the intended text while keeping the policy and its DNS responses manageable.

Separate three different limits

First, an individual TXT character-string is limited to 255 octets. SPF content is ASCII, so its ordinary characters each occupy one octet. A single TXT record can contain more than one such string. RFC 7208 section 3.3 explicitly permits that representation.

Second, the DNS response has a size. It includes names, record metadata and other TXT records returned at that owner name, not just SPF text. Section 3.4 recommends keeping SPF DNS answers small enough for legacy 512-octet UDP handling. This is a compatibility recommendation, not a universal 512-character maximum for SPF. Modern DNS transport capabilities do not eliminate every resolver, firewall or truncation problem.

Third, SPF evaluation has resource limits. Splitting text into strings does not reduce nested include processing or the ten lookup-causing-term limit. A short policy can exceed that evaluation limit; a longer list of explicit addresses may not. Assess syntax, DNS transport and evaluation cost independently.

Preserve spaces deliberately

SPF concatenates strings without inserting spaces. In a zone-file representation, "v=spf1 ip4:192.0.2.10 " "ip4:198.51.100.20 -all" produces the intended continuous policy because the first string ends with a space. Removing that space joins the two adjacent mechanisms into invalid text.

The documentation-only addresses above are illustrative. They are not authorised values for your domain. The quotation marks are zone-file presentation syntax; whether you enter them in a hosted DNS editor depends on that provider's documented interface. Some editors split long values automatically, while others expose separate string fields. Verify the served answer instead of assuming the editor's display matches the wire format.

Do not create a second TXT resource record beginning v=spf1 to hold the remainder. Multiple selected SPF records produce permerror. Conversely, do not delete unrelated TXT verification records because a diagnostic tool displays several TXT answers.

Inspect the published value

Capture the authoritative TXT response and identify which strings belong to each resource record. Reconstruct the SPF value by concatenating only the strings within its one record. Check spaces at every split boundary and ensure there is one version marker, valid mechanisms and the intended final statement.

Then test recursive DNS responses from the networks that matter. If a response is truncated or resolution fails, investigate DNS transport and provider configuration rather than deleting arbitrary mechanisms. DNSSEC and the wider answer set can affect response size; a simple character count is not a full packet-size test.

Prefer policy cleanup over clever packing

A growing policy often signals accumulated services. Review obsolete includes, unnecessarily broad mechanisms and duplicate authorisations before increasing complexity. Retain current provider-managed mechanisms when appropriate rather than copying their present IP addresses solely to shorten or reshape the record. Manually flattened addresses can become stale when providers change infrastructure.

For a policy that still needs multiple strings, save the intended unsplit text alongside the published representation. That gives future administrators a stable comparison target. A harmless editor reformat should not be confused with a semantic policy change.

Verify the reader-facing result

After an approved change, test representative sources and an unmatched source with a standards-aware evaluator, then inspect actual trusted receiver results. Record the reconstructed value, response observations and evaluation results. Close the issue when both DNS representation and authorisation behaviour are correct, not merely when the editor accepts the save.

Reconstruct a query answer

The following is a synthetic diagnostic exercise, not a query we ran or a record to publish. Substitute the actual SPF owner name and a verified authoritative nameserver before using these read-only commands. These templates use reserved example names.

dig @ns1.example.net example.com TXT +noall +answer
dig example.com TXT +noall +answer

The first command asks the specified authoritative server; the second uses the resolver configured on that machine. An answer from one recursive resolver does not prove that every receiver sees the same data. If needed, query another known resolver explicitly with @server-address.

Synthetic answer:

example.com. 300 IN TXT "v=spf1 ip4:192.0.2.10 " "ip4:198.51.100.20 -all"

Reconstructed value:

v=spf1 ip4:192.0.2.10 ip4:198.51.100.20 -all

Without the trailing space in the first string, the boundary becomes 192.0.2.10ip4:198.51.100.20. The editor might accept the TXT data, but that does not make the SPF policy valid. By contrast, two separate answer records each starting v=spf1 are a multiple-policy problem, not a string-splitting solution.

Save the queried server, owner name, timestamp and answer. Reconstruct one record at a time, compare it with the intended unsplit policy, then evaluate sender authorisation separately. The commands inspect DNS representation; they do not run a complete SPF evaluation. See RFC 7208 Section 3.3 for concatenation and Section 4.6.4 for evaluation limits.

[ By role ]

What this means for you

Choose your role for practical next steps.

IT / Mail Admin

Inspect the exact concatenated text.

A missing boundary space can change valid mechanisms into invalid syntax.

Next steps

  1. Check record boundaries separately from string boundaries.
  2. Evaluate DNS transport and SPF resource limits independently.

CISO / SecOps

Use growth as a review trigger.

A long policy may reveal an expanding authorisation surface.

Next steps

  1. Review stale includes.
  2. Require ownership for any manual address maintenance.

Founder / Non-technical

Avoid unnecessary service disruption.

A length warning is a configuration issue to diagnose, not a reason to delete vendor permissions without checking their purpose.

Next steps

  1. Have service owners validate removals.
  2. Ask for post-change message evidence.

[ FAQs ]

Frequently asked questions

Is SPF limited to 255 characters?

An individual TXT character-string is limited to 255 octets. One TXT resource record can contain multiple strings that SPF concatenates.

Does DNS add spaces between strings?

No. Preserve any required separator inside one of the strings.

Can I use two SPF TXT records instead?

No. Multiple selected SPF records create permerror. Use multiple strings within one record where needed.

Must I type quotation marks in my DNS editor?

That depends on the interface. Follow its documented syntax and inspect the published answer to confirm the resulting text.

Is 512 a hard SPF text limit?

No. RFC 7208 gives a DNS-response-size compatibility recommendation. It is not a simple maximum character count for the policy.

Does splitting reduce lookup cost?

No. The resulting SPF policy is unchanged, including its recursive evaluation work.

Why consider unrelated TXT entries?

They can be returned in the same TXT answer and contribute to DNS response size even though they are not SPF policies.

What should I save for future changes?

Save the continuous intended policy, its published record representation and evidence that expected senders evaluate correctly.

[ Sources ]

Sources

  1. RFC 7208: Sender Policy Framework

[ Glossary ]

Glossary

SPF
Sender Policy Framework: a DNS-based method for evaluating whether a connecting SMTP host is authorised to use a domain identity.
SMTP MAIL FROM
The SMTP envelope sender, also called the reverse path; it is distinct from the visible From header and can be empty.
HELO/EHLO
The SMTP client introduction and its asserted identity, used in SPF evaluation including null reverse-path handling.
DNS TXT record
A DNS resource record containing one or more character-strings. SPF concatenates strings within one record without inserting spaces.

Enterprise provenance

Why top financial institutions and governments retired their email security dashboards.

Traditional email authentication platforms sell you a dashboard and ask your engineers to do the labour. In high-stakes environments, manual oversight means delayed enforcement, configuration drift and unmonitored shadow domains.

EmailAuth is the agentic email provenance platform. Our agents enforce p=reject, keep third-party senders aligned and move your domains to full RFC 9989 compliance, the new DMARC standard,, with human-in-the-loop auditability.

Governments Large enterprises Tier-1 financial institutions

SaaS · Dedicated tenancy · Air-gapped on-prem · BYOK encryption

Knowledge Base