DigitalOcean DNS Management: Adding Mail Server Entries
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.comor 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:
- MX Hostname: The fully qualified domain name (FQDN) of your mail server (e.g.,
mail.example.comorsmtp.google.com). - Priority Value: Usually
10for a primary server and20or higher for backup servers. - 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). - Authentication Records: SPF (
TXT), DKIM (CNAMEorTXT), 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
- Log into your DigitalOcean Cloud Control Panel.
- In the left-hand navigation sidebar or top menu, click on Networking.
- Select the Domains tab.
- 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.
- In the Create new record section, select A from the record type dropdown.
- In the HOSTNAME field, enter your mail subdomain prefix (e.g.,
mail). Do not include the root domain. - In the WILL DIRECT TO field, enter your mail server's public IPv4 address (e.g.,
192.0.2.10). - Leave the TTL (Time To Live) at the default value (usually 3600 seconds) or lower it temporarily if you expect rapid changes.
- Click Create Record.
- (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.
- In the record type dropdown, select MX.
- 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. - 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.). - In the Priority field, enter
10. - 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.
- SPF Record: Create a TXT record with hostname
@and valuev=spf1 mx ip4:192.0.2.10 -all. - DKIM Record: Add the specific CNAME or TXT records provided by your email administrator or mail hosting dashboard.
- DMARC Record: Create a TXT record with hostname
_dmarcand valuev=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
- 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 insmtp.google.com.example.com. Always check your provider's formatting requirements. - 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. - 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.