TXT Records: The DNS Field That Does Everything
Learn what TXT records are used for, how email policies and ownership checks rely on them and how to enter them correctly.
Key takeaways
- TXT records hold free-form text whose meaning is defined by whatever system reads it.
- SPF, DKIM and DMARC, the main email authentication tools, are all published as TXT records or point to them.
- A name can hold many TXT records, but certain policies such as SPF must appear only once.
- Anything in public DNS is readable by anyone, so never put a secret in a TXT record.
A TXT record attaches a piece of text to a domain name. DNS itself does not care what the text says. Other systems look it up and interpret it, which is why one humble record type now carries email authentication policies, proof that you own a domain, keys for signing mail and instructions for certificate authorities.
You will most often add one because a service told you to: "create a TXT record with this value." Knowing what the common ones do helps you enter them correctly and decide which old ones are safe to remove.
What a TXT record looks like
example.com. 3600 IN TXT "v=spf1 mx -all"
example.com. 3600 IN TXT "site-verification=3f9c1e7a" Each has the usual name, TTL and class, then the type and a quoted string. The second value is a made-up example of the token style many services use.
A single string inside a TXT record is limited to 255 characters. Longer values are split into several strings within one record:
long._domainkey.example.com. 3600 IN TXT ( "v=DKIM1; k=rsa; p=FIRSTPARTOFKEY"
"SECONDPARTOFKEY" ) The reader joins the strings with nothing between them. Many dashboards split long values automatically; some expect you to do it. A stray space at a split point can corrupt a key.
The main uses
Email authentication
SPF
Sender Policy Framework lists the servers allowed to send mail using your domain in the envelope sender. It lives at the domain itself:
example.com. IN TXT "v=spf1 ip4:192.0.2.25 include:_spf.example.net -all" This allows one address, adds whatever a mail provider's policy allows and tells receivers that everything else fails. ~all instead of -all marks other senders as suspicious without a firm fail.
Two rules cause most trouble. A domain must have only one SPF record, so merge the entries when you add a service. And evaluating the policy may require no more than ten DNS lookups, which long chains of include can exceed. More in SPF explained.
DKIM
DomainKeys Identified Mail signs messages. The public key sits at a name built from a selector chosen by the sender:
selector1._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=PUBLICKEYDATA" The selector lets a domain have several keys, one per service or per rotation. Some providers ask for a CNAME to a record they manage instead. See DKIM explained.
DMARC
DMARC ties the two to the address people actually see, and asks receivers to act:
_dmarc.example.com. IN TXT "v=DMARC1; p=none; rua=mailto:[email protected]" p=none asks only for reports. quarantine and reject ask receivers to treat failing mail more strictly. Start by watching reports, as described in DMARC explained.
Reading an SPF record
Ownership verification
When you connect a domain to an email, analytics, search or business service, it needs evidence that you control the domain. It gives you a random token to publish, then looks it up. Only someone with access to the DNS could have put it there.
Keep a note of which service each token belongs to. Some services check again periodically and disconnect the domain if the record disappears. Others check once. If you do not know, ask the service before deleting it.
Certificates and other automation
Certificate authorities that use the ACME protocol can verify control of a domain with a TXT record at _acme-challenge. This DNS challenge is the usual route for wildcard certificates. The value changes with each request, so it is best automated, with credentials limited as tightly as your DNS provider allows. See automated certificates with ACME.
Other examples include policies that ask senders to use encrypted delivery (published under names such as _mta-sts and _smtp._tls), records used for logo display in some mail apps and descriptive data for network service discovery.
Underscore names
Many of these records live at labels beginning with an underscore, such as _dmarc. The underscore keeps them apart from ordinary hostnames, since names of machines do not use it. In a dashboard, enter the name exactly as given, usually without your domain on the end.
| Purpose | Where it lives | Starts with |
|---|---|---|
| SPF | The domain itself | v=spf1 |
| DKIM | selector._domainkey | v=DKIM1 |
| DMARC | _dmarc | v=DMARC1 |
| ACME challenge | _acme-challenge | A generated token |
| Ownership proof | Domain or a given name | Set by the service |
Entering them without errors
- Copy the name and value exactly; do not retype long keys.
- Check whether the dashboard adds quotation marks itself. Doubled quotes become part of the value.
- Check that the dashboard has not added your domain twice to the name.
- Watch for curly quotes or line breaks introduced by email or word processors.
- Query the record after saving.
dig example.com TXT +short
dig _dmarc.example.com TXT +short Resolve-DnsName _dmarc.example.com -Type TXT You cannot place a TXT record at a name that has a CNAME. If a service asks for that, look for an alternative verification name.
Rolling out email records in order
If you are starting from nothing, the order matters, because a strict policy applied too early can block your own legitimate mail.
- List your senders. Include the mailbox provider, the newsletter tool, the billing system, the website's contact form and anything else that sends using your domain.
- Publish SPF covering them, and check that you have exactly one record.
- Enable DKIM in each sending service and publish the keys they give you.
- Publish DMARC with
p=noneand an address for reports. - Read the reports for a few weeks. Fix any legitimate source that fails.
- Tighten the policy to quarantine, and later to reject, once the reports look clean.
A domain that never sends mail can say so directly, which makes it harder for someone to forge it convincingly:
example.net. IN TXT "v=spf1 -all"
_dmarc.example.net. IN TXT "v=DMARC1; p=reject" Large mailbox providers publish their own requirements for senders, and these change, so check them if you send in volume.
Troubleshooting by symptom
| Symptom | Likely cause |
|---|---|
| SPF reports a permanent error | Two SPF records, a syntax slip or too many lookups |
| DKIM fails for one service only | Wrong selector name or a truncated key |
| DMARC reports never arrive | Record at the wrong name, or a mistyped report address |
| Verification keeps failing | Token added at www when the service wants the bare domain, or the reverse |
| Value shows extra quotes | Quotation marks typed into a dashboard that adds its own |
When in doubt, query the domain's authoritative server directly, so that you see what is published now and not what a cache remembers:
dig @ns1.example.com _dmarc.example.com TXT +short Replace the server name with one of your domain's actual name servers. If the record is correct there, the remaining problem is either caching or the way the checking service reads it.
Security and tidiness
Everything in public DNS can be read by anyone who asks. Tokens used for verification are meant to be public, and so is a DKIM public key. Private keys, passwords and internal notes must never go there. Even harmless-looking records reveal which services your organization uses, which can help someone craft a convincing fake message.
A long list of old records also has practical costs. Large responses are more likely to need a fallback to TCP, and nobody can tell which entries matter. Review the list now and then:
- Identify each record's owner and purpose.
- Remove verification tokens for services you have confirmed no longer need them.
- Drop
includeentries in SPF for senders you have stopped using, since each one leaves that company able to pass your check. - Retire old DKIM selectors after the rotation period has passed.
Because the account that edits DNS can publish any of these, it can also be used to authorize a stranger's mail servers or obtain certificates for your names. Protect it with strong, unique sign-in credentials and multi-factor authentication, and review who has access.
Common questions
How many TXT records can one name have?
DNS sets no small fixed limit, and busy domains often collect a good number at the top. Keep only the ones you can explain.
Does the order of TXT records matter?
No. A resolver may return them in any order, and readers pick out the one with the prefix they expect.
Why does a service say my record is missing when I can see it?
The service may have cached the earlier "not found" answer, or the record may be at a slightly different name. Compare the exact name, then allow for caching.
Is there a dedicated SPF record type?
One was once defined, but it was dropped from the standard. Publish SPF as TXT.