Skip to main content
WisMail

Mail server DNS: MX, SPF, DKIM, DMARC, PTR

DNS decides whether your mail arrives or lands in spam. This guide lists every record a self-hosted mail server needs, in the order to create them, and the command that proves each one. The examples use the domain example.com and the server mail.example.com with IP address 203.0.113.10: replace them with yours. Allow about 20 minutes, plus the time DNS needs to propagate. Why these records matter: email authentication.

1. A record and host name

Create an A record (and an AAAA record if you use IPv6) for the server name, and use the same name as the server host name in the install guide:

mail.example.com.   A    203.0.113.10
dig +short A mail.example.com

2. MX record

The MX record tells other servers where to deliver mail for your domain. It must point to a host name (not an IP address):

example.com.        MX   10 mail.example.com.

The setup wizard checks the MX record of your primary domain. Verify:

dig +short MX example.com

3. PTR (reverse DNS)

Many receiving servers reject mail from an IP address without matching reverse DNS. The PTR record is not in your DNS zone: ask your infrastructure provider (or set it in their control panel) to point the PTR of 203.0.113.10 to mail.example.com, the same name as the A record and the host name in the setup wizard.

dig +short -x 203.0.113.10

The answer must be mail.example.com.

4. SPF

SPF lists the servers allowed to send mail for the domain:

example.com.   TXT   "v=spf1 mx -all"

mx lets the servers in the MX record send mail, and -all rejects everything else. Create only one SPF record per domain. If you send through an external relay, add that provider's include: before -all (see SMTP relay). WisMail also checks SPF on incoming mail.

5. DKIM

DKIM signs outgoing mail so receivers can verify it came from you.

Web administration domain settings: DKIM section with the TXT record to copy into DNS
  1. In web administration open Configuration, Domains, edit the domain and turn on DKIM signing.
  2. The server creates a key and shows the TXT record to create, with a button to copy it. It looks like:
mail._domainkey.example.com.   TXT   "v=DKIM1; k=rsa; p=MIIBIjANBgkq..."
  1. Create the record in your DNS. When DNS returns the right key the server starts signing outgoing mail; if the record is missing or wrong the server logs it and does not sign. DNS changes can take a while to appear.

The default selector is mail. Check:

dig +short TXT mail._domainkey.example.com

Each mail domain has its own key and record.

6. DMARC

DMARC tells receivers what to do with mail that fails SPF and DKIM and where to send reports. Start in monitoring mode:

_dmarc.example.com.   TXT   "v=DMARC1; p=none; rua=mailto:[email protected]"

After a few weeks of reading reports, once your legitimate mail all passes, raise p=none to p=quarantine, then p=reject. Note: WisMail only helps you publish the record. Reports are sent by receiving servers to your rua mailbox; WisMail does not generate reports and does not evaluate the DMARC policy of incoming mail.

7. Autodiscover for Outlook and devices

The server answers Autodiscover at /autodiscover/autodiscover.xml over HTTPS. Create a name so that apps can find it:

autodiscover.example.com.   CNAME   mail.example.com.

The server certificate must cover autodiscover.example.com. The Let's Encrypt screen issues for one host name, so for this name import a certificate that lists both names (SSL guide). We have not tested SRV records; if your clients rely on SRV, try them during the trial.

8. Final check

  1. Run the dig commands above. Each must return the expected value.
  2. Send a message to your Gmail or Outlook.com address, open Show original and look for SPF: PASS and DKIM: PASS.
  3. If a record does not show up, wait for the TTL to expire and query again; you can also check with an online DNS or mail-test tool.

For more depth read SPF, DKIM and DMARC for a self-hosted mail server.

Next steps