How to Configure DNS Records for a Mail Server
Proper DNS configuration is essential for a mail server to function correctly, ensure reliable email delivery, and prevent messages from being marked as spam.
When installing the mail server module in the BeAdmin
Control Panel, you’ll need to specify the domain that will be used for the mail system. Although this domain can be changed later, it is required during the initial setup. For the purposes of this guide, we’ll use example.com
as the domain and 192.0.2.10
as the server’s IP address.
It is recommended to create DNS records through your domain registrar or hosting provider. Their DNS servers are typically highly available and ensure stable performance for your services.
A Record (Address Record)
Specifies the IP address of your mail server.
mail.example.com. IN A 192.0.2.10
Assuming your website is hosted on the same server, make sure there is also an A record for the root domain. If it doesn’t exist yet, add it:
example.com. IN A 192.0.2.10
Important
The mail.example.com name will be used in the MX record and must point to a real IP address.
MX Record (Mail Exchange)
Indicates which server is responsible for receiving emails.
example.com. IN MX 10 mail.example.com.
The number 10
represents priority. The MX record should point to a subdomain with a valid A record.
SPF Record (Sender Policy Framework)
Helps prevent email spoofing by specifying allowed senders.
example.com. IN TXT "v=spf1 ip4:192.0.2.10 -all"
The -all
tag tells recipient servers to reject mail from any other IPs.
DKIM Record (DomainKeys Identified Mail)
Verifies that emails have not been tampered with and are sent on behalf of your domain. This record contains the public key.
default._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBg..."
The private key is stored on the server and used to sign outgoing messages.
DMARC Record
Defines how to handle emails that fail SPF or DKIM checks.
_dmarc.example.com. IN TXT "v=DMARC1; p=reject; rua=mailto:admin@example.com"
The p=reject
directive tells receiving servers to reject messages that fail authentication.
PTR Record (Reverse DNS)
A reverse DNS record that maps an IP address back to a domain name. This is usually configured through your hosting provider.
10.2.0.192.in-addr.arpa. IN PTR mail.example.com.
Warning
The PTR record must match the HELO/EHLO name used by your mail server.
Configuration Example
Assuming:
- Domain:
example.com
- Host:
mail.example.com
- IP address:
192.0.2.10
The DNS records should look approximately like this:
mail.example.com. IN A 192.0.2.10
example.com. IN MX 10 mail.example.com.
example.com. IN TXT "v=spf1 ip4:192.0.2.10 -all"
_dmarc.example.com. IN TXT "v=DMARC1; p=reject; rua=mailto:admin@example.com"
default._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBg..."
Helpful Tips
- Check your DNS records at: https://mxtoolbox.com
- Test email delivery using: https://mail-tester.com
- Make sure PTR, HELO, and A records are consistent
- Regenerate DKIM keys if the server or domain configuration changes