Skip to content

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. The "Mail DNS" dialog shows which records a domain needs and whether they are published correctly: open it for the domain in "Websites & Domains". Below, we explain what each record is for and how to create it.

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 the A, MX, SPF, DKIM, and DMARC records through your domain registrar or hosting provider. Their DNS servers are typically highly available and ensure stable performance for your services. The PTR record works differently: it belongs to the server’s IP address, not to the domain, so it is created only with the server’s hosting provider, that is, the company you rent the server from. You cannot create it at your domain registrar.

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

💡 Tip

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 maps an IP address to a domain name, so it works in the opposite direction to an A record. Receiving mail servers check it to make sure the message came from a genuine mail server. Without a PTR record, emails land in spam or get rejected.

The mail server sends mail over IPv4, so the PTR record is needed for the server’s IPv4 address. Create it with the server’s hosting provider, not at your domain registrar: the record belongs to an IP address, and whoever issued the address controls it. This setting is usually called "Reverse DNS", "rDNS", or "PTR" and is found in the server or IP address settings in your hosting provider’s account. If you cannot find it there, ask the provider’s support to create the record.

⚠️ Sending over IPv6 is not supported

The mail server sends email only over IPv4, but receives it over both IPv4 and IPv6. The reason is that major mail services, such as Gmail, reject messages from an IPv6 address without a PTR record, and many hosting providers do not let you create a PTR record for an IPv6 address.

If the server has no public IPv4 address, emails will not be sent, but receiving will keep working. The panel warns you about this during module installation, and in the "Mail" section it shows the "Emails are not being sent" warning. Add an IPv4 address through your hosting provider.

In the PTR record, enter the mail server address:

10.2.0.192.in-addr.arpa.    IN    PTR    mail.example.com.

The name in the PTR record must, in turn, point back to the same IP address: for mail.example.com, you need an A record for 192.0.2.10. This pair — PTR from the address to the name and A from the name back to the address — is called forward-confirmed reverse DNS (FCrDNS), and receiving servers check exactly that.

The name the mail server identifies itself with when sending mail (HELO) is taken from the PTR record automatically, so there is no need to match it to the PTR record. You can set your own name in the module settings, but this is rarely needed.

PTR record status in the panel ​

The panel checks the PTR record of the server’s IPv4 address and shows the result in the "Mail DNS" dialog: open it for the domain in "Websites & Domains". The PTR record can have the following statuses:

  • "Configured" — the PTR record exists, and the name in it points to the server’s IPv4 address. No changes needed.
  • "No record" — there is no PTR record. Set it with the server’s hosting provider.
  • "Doesn't match IP" — the PTR record exists, but the name in it does not point to the server’s IPv4 address. Add an A record with the server’s IP address for this name, or change the PTR record with the hosting provider.
  • "Not checked" — the record could not be checked, for example because DNS did not respond: try again later. A server behind NAT has the same status: the panel detects only its internal address and cannot check the PTR record of the public one. In that case, check the record with the hosting provider.

After changing the PTR record, click "Check DNS": the check result is kept for a short time, and a new record does not appear in DNS right away.

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..."

The PTR record is not part of this list: it is created with the server’s hosting provider, not in the domain’s DNS. It looks like this:

10.2.0.192.in-addr.arpa.        IN PTR   mail.example.com.

Helpful tips ​

  • Check your DNS records at: https://mxtoolbox.com
  • Test email delivery using: https://mail-tester.com
  • Make sure the PTR and A records are consistent: the name in the PTR record must point to the server’s IP address. In the "Mail DNS" dialog, such a PTR record has the "Configured" status. There is no need to match HELO to them: it is taken from the PTR record automatically
  • Make sure the server has a public IPv4 address: without it, emails are not sent
  • Regenerate DKIM keys if the server or domain configuration changes

BeAdmin © 2025. All rights reserved.