Skip to content

TXT records in a busy zone — verification, SPF, and the noise

Clean up the TXT records in a busy cPanel DNS zone, where email authentication records and old service verification codes pile up. List everything the zone publishes, merge duplicate SPF records into one, and remove leftovers that make troubleshooting harder.

TXT records pile up in a cPanel DNS zone over the years, and a short cleanup makes email and certificate problems much easier to troubleshoot. They hold free-form text and carry email authentication records, ownership-verification codes for services such as Google or Microsoft 365, and the temporary _acme-challenge records some certificate requests use. Over time a zone gathers codes for tools nobody uses and, often, a second SPF record, the list of servers allowed to send mail for your domain, even though only one is valid. Merge every SPF include: into a single record, delete DKIM selectors (named signing keys) that your mail system no longer uses, and remove leftover _acme-challenge entries.

What’s happening

The TXT record type is the kitchen drawer of DNS. SPF (RFC 7208) lives in TXT. DKIM public keys live in TXT under selectors. DMARC lives in TXT under _dmarc. SaaS verifications (Google site verification, Microsoft 365 onboarding, Atlassian, Slack, Stripe, et cetera) all use TXT. ACME’s DNS-01 challenge for cert issuance uses TXT at _acme-challenge.<name>. Each is a valid use.

The mess starts when:

  • An SPF record at the apex coexists with a second TXT that also starts with v=spf1 — only one is valid per RFC, and senders pick the first they see, which may not be the one you intend.
  • Two DKIM selectors are publishing keys but one was rotated out and never re-deleted — the old selector still validates if mail signed with it shows up, which it shouldn’t.
  • A _acme-challenge TXT from a one-off cert request is now permanent in the zone — it’s not harmful but it can mislead anyone troubleshooting cert issuance.

How to verify

List every TXT in the zone:

whmapi1 dumpzone domain=example.com | grep ' TXT '
dig +short TXT example.com
dig +short TXT _dmarc.example.com
dig +short TXT default._domainkey.example.com

For SPF, confirm there’s exactly one record starting with v=spf1:

dig +short TXT example.com | grep -c '^"v=spf1'

If that returns more than 1, the zone has duplicate SPF and senders see undefined behaviour.

For DKIM, list every selector:

whmapi1 dumpzone domain=example.com | grep -E '_domainkey.*TXT'

Every selector publishing a key here should match a selector your mail system actively signs with.

What to do

  1. One SPF record at the apex. Combine all include: directives into a single v=spf1 include:... include:... ~all (or -all once validated). Multiple SPF records is a configuration bug, not a feature.
  2. Prune dormant DKIM selectors. If a selector has been retired for more than the longest mail-flight window (typically two weeks), delete it. The selector is referenced by message headers; once those messages have been delivered or bounced, the public key is no longer needed.
  3. Delete _acme-challenge leftovers unless you’re running a continuous DNS-01 cert renewal. ACME’s challenge records are meant to be ephemeral.
  4. Document SaaS verifications in the zone as comments (cPanel’s raw zone editor in WHM allows comments). When a verification’s TXT looks unfamiliar three years later, you’ll thank yourself for noting “Stripe site verification, added 2024-03”.
  5. Use the SPF lookup-limit counter every time you add an include:. The hard limit is 10 DNS lookups during SPF evaluation, and many include: directives chain to more includes — _spf.google.com alone uses a few. Tools like mxtoolbox.com give the count.

Periodic zone hygiene — quarterly, or on every customer takeover — keeps the TXT pile lean and the next person troubleshooting a delivery issue or cert renewal less frustrated.

Stack Harbor performs zone hygiene on multi-domain fleets during onboarding as part of cPanel server administration.