XiaTools

MX Records vs TXT Records: Understanding Email Authentication DNS

Updated 14 Oct 2026

When configuring domain name system settings for mail delivery, understanding mx record vs txt record explained properly saves you from lost messages and spoofing attacks. MX records tell sending servers where to deliver incoming mail for your domain, while TXT records hold the cryptographic keys that prove your identity through standards like SPF, DKIM, and DMARC. Without a properly configured mail exchange entry, nobody can send you a message, and without text entries, your outgoing messages land straight in the spam folder.

Before making any DNS changes, it helps to understand what technologies your domain currently runs on by using the Website Technology Checker to inspect your mail servers and security configurations instantly.

Core Concepts: MX Records and TXT Records

To configure your domain correctly, you must understand the distinct roles these two DNS resource types play in email architecture.

What is an MX Record?

An MX (Mail Exchange) record is a fundamental DNS setting that directs inbound email to the correct mail server handling a domain. When a user on an external mail server hits send, their provider performs an MX lookup for your domain name to find out which host accepts your mail.

An MX record consists of two primary components:

  • Priority: A preference number (usually 10, 20, etc.) where lower numbers indicate higher preference.
  • Target Hostname: The fully qualified domain name (FQDN) of the receiving mail server.
example.com. IN MX 10 mail.example.com.
example.com. IN MX 20 mailbackup.example.com.

What is a TXT Record?

A TXT (Text) record lets domain administrators insert arbitrary text into the DNS. While historically used for simple human-readable notes, modern network engineers rely on TXT entries almost exclusively for machine-readable security policies and domain verification.

Email authentication relies heavily on TXT records to publish:

  • SPF (Sender Policy Framework): Lists authorized IP addresses allowed to send mail for the domain.
  • DKIM (DomainKeys Identified Mail): Publishes the public cryptographic key used to verify digital signatures on outgoing messages.
  • DMARC (Domain-based Message Authentication, Reporting, and Conformance): Dictates how receiving servers should treat emails that fail SPF or DKIM checks.
example.com. IN TXT "v=spf1 ip4:192.0.2.1 include:_spf.example.com ~all"

Comparison Table

Feature MX Record TXT Record
Primary Purpose Directs inbound message delivery Secures outbound delivery and proves domain ownership
Data Format Priority integer + Target hostname String of key-value pairs or public keys
Impact of Missing Inbound messages bounce immediately Outbound messages flagged as spam or rejected
Lookup Frequency Every incoming message Every outgoing message (by receiving server)
Standard TTL 3600 to 86400 seconds 3600 to 86400 seconds

Step-by-Step Configuration Guide

Configuring these records requires access to your DNS hosting provider's management console. While menu paths vary by provider, you typically look for a section labeled DNS Manager, Zone Editor, or Namecheap BasicDNS/Cloudflare DNS.

Step 1: Add Your MX Records

  1. Log into your DNS management dashboard and navigate to your domain's DNS zone file.
  2. Click Add Record and select MX from the record type dropdown menu.
  3. Enter @ or leave the host field blank to apply the record to the root domain (example.com).
  4. Set the Priority to 10.
  5. Enter the target mail server hostname provided by your email host, such as mail.example.com.
  6. Save the record. Repeat this process if your provider supplies a secondary backup server with a lower priority number like 20.

Step 2: Add Your SPF TXT Record

  1. In your DNS manager, click Add Record and select TXT.
  2. In the host or name field, enter @ or your root domain.
  3. In the value or text field, paste your SPF policy string:

v=spf1 ip4:192.0.2.0/24 include:mail.example.com ~all

4. Save the record. Ensure you only have one active SPF record per domain.

### Step 3: Add Your DMARC TXT Record

1. Create a new **TXT** record.
2. In the host field, enter `_dmarc` (note the underscore prefix).
3. In the value field, paste a basic monitoring policy string:
```text
v=DMARC1; p=none; rua=mailto:admin@example.com
  1. Save the record.

Troubleshooting DNS Records Using Command Line Tools

Verifying your DNS updates requires checking live propagation from public resolvers. Open your terminal or PowerShell console to run standard diagnostic commands.

Checking MX Records with dig

Query Google's public DNS resolver for your domain's MX configuration:

dig @8.8.8.8 example.com MX

Sample output:

;; QUESTION SECTION:
;example.com.			IN	MX

;; ANSWER SECTION:
example.com.		300	IN	MX	10 mail.example.com.
example.com.		300	IN	MX	20 mailbackup.example.com.

Checking TXT Records with nslookup

Use nslookup on Windows or Linux to verify your SPF and DMARC text entries:

nslookup -type=TXT example.com

Sample output:

Server:		8.8.8.8
Address:	8.8.8.8#53

Non-authoritative answer:
example.com	text = "v=spf1 ip4:192.0.2.0/24 ~all"

To check your DMARC record specifically, query the subdomain:

nslookup -type=TXT _dmarc.example.com

Common Mistakes and How to Fix Them

  • Multiple SPF Records: Having two or more SPF TXT records breaks authentication completely because receiving servers do not know which policy to trust. Merge all allowed IP ranges and includes into a single TXT record.
  • Missing Underscore on DMARC: Forgetting the leading underscore in _dmarc.example.com causes mail servers to ignore your policy entirely.
  • Incorrect MX Priority Values: Using negative numbers or formatting priorities incorrectly will cause DNS parsers to reject the record.
  • Codenaming CNAME Conflicts: Never point an MX record to a target hostname that resolves via a CNAME record. MX targets must point directly to an A or AAAA record.

Pre-Deployment Checklist

  • MX records point to valid hostnames with correct priority numbers.
  • Only a single SPF TXT record exists for the root domain.
  • DKIM public key record is published at the specific selector subdomain provided by your email host.
  • DMARC record is published at _dmarc.example.com with a monitoring policy (p=none).
  • TTL values are set low (e.g., 300 seconds) prior to making changes, then increased once stable.
  • Live DNS queries executed via dig or nslookup confirm global propagation.

Frequently asked questions

Can an MX record point directly to an IP address?

No, standard RFC specifications require MX records to point to a valid hostname (an A or AAAA record), never directly to an IP address. Pointing an MX record to an IP address will cause receiving mail servers to reject the configuration.

What happens if my domain has no MX records?

Without MX records, external mail servers have no designated host to deliver incoming messages to. Senders will receive an immediate permanent failure bounce message, and you will not receive any emails at your domain.

Why do I need multiple TXT records for email?

Email security standards like SPF, DKIM, and DMARC serve completely different verification functions and require independent configurations. Splitting them into separate TXT records lets receiving servers evaluate your IP authorization, cryptographic signatures, and policy enforcement rules individually.

How long does it take for MX and TXT records to update?

DNS propagation typically takes anywhere from a few minutes to 24 hours. The exact duration depends on the Time to Live (TTL) values configured on your old records and how quickly global recursive resolvers flush their caches.

Can I use the same TXT record for SPF and DMARC?

No, SPF and DMARC must be kept in entirely separate TXT records. SPF sits on the root domain, while DMARC must be published on the specific `_dmarc` subdomain.

Related articles

Free tools