XiaTools

DigitalOcean DNS Management: Adding Mail Server Entries

By Rohit, founder of XiaTools · Updated 20 Oct 2026

Configuring mail server entries for your domain on DigitalOcean requires setting up correct MX and related DNS records to ensure your emails reach the inbox instead of the spam folder. Whether you are self-hosting a mail server or connecting to an external provider like Google Workspace or Microsoft 365, accurate DNS routing is critical. Before making updates, verify your current mail routing setup using the MX Lookup tool to check existing records and ensure a clean transition without delivery downtime.

Understanding DigitalOcean DNS and MX Records

DigitalOcean manages DNS through its reliable, anycast-enabled nameserver infrastructure. When an email server on the internet wants to send a message to user@example.com, it queries the global DNS system for the Mail Exchange (MX) records associated with example.com.

An MX record consists of two main components:

  • Priority: A lower number indicates a higher preference. If your primary mail server is offline, sending servers will try the server with the next higher priority number.
  • Hostname: The destination mail server address (e.g., mail.example.com or a provider's designated routing domain).

Unlike traditional web hosting panels, DigitalOcean's control panel separates droplet management from networking and DNS. You must add your domain to the Networking > Domains section before you can create MX, A, CNAME, TXT, and SRV records.

Prerequisites Before You Begin

Before you log into your DigitalOcean control panel, gather the exact information required by your email provider or your self-hosted mail server architecture:

  1. MX Hostname: The fully qualified domain name (FQDN) of your mail server (e.g., mail.example.com or smtp.google.com).
  2. Priority Value: Usually 10 for a primary server and 20 or higher for backup servers.
  3. Supporting Records: Most mail servers require an A record for the mail subdomain pointing to your mail server's IPv4 address (e.g., 192.0.2.10), and often an AAAA record for IPv6 (2001:db8::10).
  4. Authentication Records: SPF (TXT), DKIM (CNAME or TXT), and DMARC (TXT) records to pass anti-spam checks.

Step-by-Step DigitalOcean MX Records Tutorial

Follow these precise steps to add and manage your mail server entries inside the DigitalOcean control panel. Note that user interface menus and labels may differ slightly as DigitalOcean updates its platform design.

Step 1: Access Your Domain in DigitalOcean

  1. Log into your DigitalOcean Cloud Control Panel.
  2. In the left-hand navigation sidebar or top menu, click on Networking.
  3. Select the Domains tab.
  4. If you have not added your domain yet, enter your domain name (e.g., example.com), select your project, and click Create Domain. If it is already added, click on the domain name to open its DNS record management table.

Step 2: Create A and AAAA Records for Your Mail Server

If you are using a custom mail subdomain like mail.example.com, you must point it to your server's IP address before adding the MX record.

  1. In the Create new record section, select A from the record type dropdown.
  2. In the HOSTNAME field, enter your mail subdomain prefix (e.g., mail). Do not include the root domain.
  3. In the WILL DIRECT TO field, enter your mail server's public IPv4 address (e.g., 192.0.2.10).
  4. Leave the TTL (Time To Live) at the default value (usually 3600 seconds) or lower it temporarily if you expect rapid changes.
  5. Click Create Record.
  6. (Optional) Repeat the process selecting AAAA if you support IPv6, entering your server's IPv6 address (e.g., 2001:db8::10).

Step 3: Add the MX Record

With your mail server hostname resolved via an A record, you can now add the MX pointer.

  1. In the record type dropdown, select MX.
  2. In the HOSTNAME field, leave it blank (@) if the mail is for your root domain (example.com), or enter a subdomain if you are setting up mail for a specific sub-zone.
  3. In the WILL DIRECT TO (or Mail Server) field, enter your mail server's FQDN ending with a trailing dot if required by the interface (e.g., mail.example.com.).
  4. In the Priority field, enter 10.
  5. Click Create Record.
Record Type Hostname Value / Target Priority Purpose
A mail 192.0.2.10 - Points mail subdomain to server IP
MX @ mail.example.com. 10 Directs root domain mail traffic
TXT @ v=spf1 ip4:192.0.2.10 -all - Authorizes mail server via SPF

Step 4: Add Email Authentication Records (SPF, DKIM, DMARC)

Modern email security demands strict authentication. Without these records, mail providers like Gmail and Yahoo will reject or quarantine your messages.

  1. SPF Record: Create a TXT record with hostname @ and value v=spf1 mx ip4:192.0.2.10 -all.
  2. DKIM Record: Add the specific CNAME or TXT records provided by your email administrator or mail hosting dashboard.
  3. DMARC Record: Create a TXT record with hostname _dmarc and value v=DMARC1; p=none; rua=mailto:admin@example.com.

Verifying Your DigitalOcean Mail Setup

After saving your records, allow a few minutes for DNS propagation across global recursive resolvers. You can verify your configuration directly from your terminal using standard diagnostic utilities.

Using dig to Check MX Records

Run the following command in your terminal to query the MX records for your domain:

dig example.com MX +noall +answer

Expected output sample:

example.com.		3600	IN	MX	10 mail.example.com.

Using nslookup on Windows PowerShell

To check your setup on Windows systems, open PowerShell and run:

Resolve-DnsName -Name example.com -Type MX

Common Mistakes and How to Fix Them

  1. Missing Trailing Dot on External Hostnames: When pointing an MX record to an external provider (e.g., smtp.google.com), forgetting the trailing dot can cause DigitalOcean to append your root domain automatically, resulting in smtp.google.com.example.com. Always check your provider's formatting requirements.
  2. Conflicting CNAME and MX Records: Never create a CNAME record for your root domain (example.com) while attempting to add an MX record to it. DNS standards prohibit CNAME records from coexisting with other records at the same name.
  3. Incorrect Priority Values: Setting a backup mail server with a lower priority number than your primary server will cause mail traffic to route incorrectly to the backup node first.

DNS Management Quick Checklist

  • Domain added to DigitalOcean Networking > Domains.
  • A record created for mail server subdomain (mail.example.com).
  • MX record created with correct priority (e.g., 10) and target hostname.
  • SPF TXT record added to authorize sending IPs.
  • DKIM and DMARC records configured for anti-spoofing protection.
  • Verified record propagation using command-line tools.

Frequently asked questions

How long do DigitalOcean DNS changes take to update?

DigitalOcean DNS changes typically propagate globally within 30 to 60 seconds due to their anycast nameserver network. However, local ISP caching and mail server lookup caches can delay actual traffic routing for up to a few hours based on the configured TTL.

Can I use a CNAME record for my MX record target?

No, RFC standards strictly prohibit pointing an MX record to a CNAME alias. Your MX record must point directly to an A or AAAA record that resolves to an IP address.

Why are my emails going to spam even with MX records configured?

MX records only control where inbound mail is delivered. Outbound deliverability issues are almost always caused by missing or incorrect SPF, DKIM, or DMARC records, or because your server's IP address lacks a valid Reverse DNS (PTR) record.

How do I set up a backup mail server on DigitalOcean?

To set up a backup mail server, add a second MX record pointing to your secondary mail server hostname with a higher priority number, such as `20`. If your primary server goes offline, sending mail servers will automatically fallback to the secondary server.

Do I need to configure Reverse DNS (PTR) for mail delivery?

Yes. If you are self-hosting your mail server on a DigitalOcean Droplet, you must configure a PTR record (reverse DNS) in your droplet settings so that your server IP resolves back to your mail hostname.

Related articles

Free tools