Most DNS trouble comes from five record types. Here is what each one does, with the mail setup that decides whether your messages reach the inbox.
The records
| Type | Answers the question | Example |
|---|---|---|
| A | Which IPv4 address is this name? | www to 203.0.113.10 |
| AAAA | Which IPv6 address is this name? | www to 2001:db8::10 |
| CNAME | Which other name is this an alias of? | shop to www.example.com |
| MX | Which server receives mail for this domain? | @ to mail.example.com, priority 10 |
| TXT | Free text, used for verification and mail policy | SPF, DKIM, DMARC |
| PTR | Which name belongs to this address? (the reverse) | 203.0.113.10 to mail.example.com |
Rules that catch people:
- A CNAME cannot sit next to other records for the same name, and it cannot be used for the bare domain (
@) on ordinary DNS. - An MX record must point to a name that has an A record, not to a CNAME and not to an IP address.
- PTR is not set where you manage your domain. It belongs to whoever owns the IP address, which is your hosting provider.
TTL
TTL is how long resolvers may remember an answer, in seconds. A low value (300) makes changes spread fast. A high value (3600 or more) means fewer lookups. Lower the TTL a day before a planned move, and raise it again afterwards.
A lookup that failed is remembered too. If you query a record before you create it, your resolver may keep answering “does not exist” for a while after it is there. Ask the authoritative server directly to see the truth:
dig NS example.com +short
dig TXT _dmarc.example.com @ns1.your-dns-host.example +short
Mail: four things must agree
A server that sends mail for your domain needs all four. Missing any one is a common reason for the spam folder.
1. SPF: which servers may send
One TXT record on the bare domain:
v=spf1 ip4:203.0.113.10 ~all
There may be only one SPF record per name. Two records count as an error and both are ignored. If your DNS host added one by itself for a forwarding service, change or remove that one instead of adding a second.
2. DKIM: a signature on each message
Your mail server signs outgoing mail with a private key. The public key goes into a TXT record at selector._domainkey:
s1._domainkey TXT v=DKIM1; k=rsa; p=MIIBIjANBg...
The record is long. Paste it as one value and let the DNS host split it.
3. DMARC: what receivers should do
_dmarc TXT v=DMARC1; p=none
Start with p=none, which only reports. Move to quarantine and then reject once you are sure every legitimate sender passes SPF or DKIM.
4. PTR: the address must have a name
The receiving server looks up the name of your IP address, and then checks that this name points back to the same address. The name should also match what your server says when it connects.
dig -x 203.0.113.10 +short
dig A mail.example.com +short
If the first command returns nothing, large mail providers will distrust your mail no matter how good SPF and DKIM are. This is the part people forget, because it is set in the hosting panel and not in DNS.
Check your work
dig TXT example.com +short
dig TXT s1._domainkey.example.com +short
dig TXT _dmarc.example.com +short
dig MX example.com +short
Then send a message to a mailbox you own at a large provider and open the original headers. You want to see spf=pass, dkim=pass and dmarc=pass. Each fail tells you which of the four to fix.
A new domain is still a new domain
Even with everything correct, the first messages from a brand new domain may go to spam. Reputation builds from real mail that people open. Send normal volumes, avoid messages that are just a link, and mark your own test messages as not spam.