What is a TXT Record?
A TXT record (Text record) allows a domain administrator to store text in the Domain Name System. Historically, it was used for human-readable notes, but today it's primarily used for automated systems to verify domain ownership and secure email delivery.
Structure of a TXT Record
example.com. 3600 IN TXT "v=spf1 include:_spf.google.com ~all"
- Host: The hostname (often the root
@or a specific subdomain). - TTL: Time to Live.
- Type:
TXT. - Value: Any text string (up to 255 characters per string, though records can contain multiple strings).
Common Use Cases
Domain Verification
Services like Google, Microsoft, and various SaaS platforms require you to add a specific TXT record to prove you own the domain.
google-site-verification=ABC123XYZ...
SPF (Sender Policy Framework)
Lists the mail servers that are authorized to send email on behalf of your domain. This helps prevent spam and spoofing.
v=spf1 include:_spf.google.com ~all
DKIM (DomainKeys Identified Mail)
Adds a digital signature to every email you send, allowing the receiver to verify that the email was actually sent from your domain and wasn't tampered with.
v=DKIM1; k=rsa; p=MIGfMA0GCSq...
DMARC
Tells receiving servers what to do if an email fails SPF or DKIM checks (e.g., ignore it, quarantine it, or reject it entirely).
v=DMARC1; p=reject; rua=mailto:[email protected]
Technical Detail: Character Limits
A single TXT string is limited to 255 characters. However, a single TXT record can contain multiple strings. If your record (like a long DKIM key) exceeds 255 characters, your DNS provider should handle splitting it into multiple quoted strings.