MX (Mail Exchange) records tell the internet which servers handle incoming email for your domain. Misconfigured MX records are one of the most common reasons incoming email simply never arrives.
Understanding MX Record Priority
Each MX record has a priority number — lower numbers are tried first. Multiple MX records provide redundancy: if the primary server is unreachable, mail is delivered to the next-priority server.
Priority 10: mail.yourdomain.com
Priority 20: mail-backup.yourdomain.com
Scenario 1 — Self-Hosted Mail Server
If you're running your own mail server on your VPS (see How to Install and Configure Postfix as a Mail Transfer Agent):
Type: MX
Name: @
Priority: 10
Value: mail.yourdomain.com
TTL: 3600
Ensure a corresponding A record exists for mail.yourdomain.com pointing to your VPS's IP.
Scenario 2 — Using a Third-Party Email Service
If you're using a hosted email provider instead of self-hosting, use the exact MX records they specify in their setup documentation — these vary by provider and are typically provided as a specific list to copy exactly.
Step-by-Step: Adding an MX Record
- Log in to your DNS management panel
- Add a new record, selecting type MX
- Set Name to
@(or a subdomain, if using subdomain-based email) - Enter the mail server hostname as the value
- Set the priority number
- Save
Verifying MX Records
dig MX yourdomain.com +short
Common Mistakes
- Using an IP address as the MX value instead of a hostname — MX records must point to a hostname, which itself must resolve via an A record
- Forgetting the corresponding A record for the mail server hostname
- Leaving old MX records from a previous email provider active alongside new ones, causing routing conflicts
- Not setting SPF/DKIM/DMARC alongside MX — MX alone doesn't authenticate outbound mail; see How to Configure SPF, DKIM, and DMARC
Testing Incoming Mail Delivery
Send a test email from an external account (Gmail, Outlook) to an address at your domain, then confirm it arrives and check headers if it doesn't.
Common Errors
Email bounces with "mailbox unavailable" or similar — often not an MX issue but a mailbox configuration problem on the receiving server; verify the mail server itself is running and configured for that domain.
"No MX record found" — the record wasn't saved, or hasn't propagated yet; verify with dig MX.
Mail delivered inconsistently — check if multiple conflicting MX records exist from different providers/setups.
Best Practices
- Always pair MX records with proper SPF, DKIM, and DMARC configuration
- Remove old MX records completely when switching email providers, don't just add new ones alongside
- Use a dedicated mail subdomain (
mail.yourdomain.com) rather than the bare root domain as the MX target
Related Articles
- How to Install and Configure Postfix as a Mail Transfer Agent
- How to Configure SPF, DKIM, and DMARC (Complete Guide)
- DNS Fundamentals: A, AAAA, CNAME, MX, TXT & NS Records Explained
