ULTIMATE GUIDE: Setting Up Your Server for Reliable Email Delivery. PART 2: How to prevent outgoing emails from going to spam

DNS records are a set of technical parameters of a domain that determine where to route different types of traffic: web, mail, FTP, etc.
They link the domain name to IP addresses and other servers so that browsers and mail systems know where to connect when working with your website or email.
In Part 1 of this guide, we configured the firewall and opened the necessary ports for mail delivery. Now that we have made sure that messages are being sent from your server, we need to check that the DNS records are configured correctly. Gmail, Outlook, and other major mail services strictly verify MX, SPF, DKIM, DMARC, and PTR before delivering messages to the primary inbox. Correct records sharply increase the chance that messages will land in the Inbox folder instead of Spam (or be completely rejected).
In the following steps, we will describe how to check the current DNS records of each type and provide recommendations on how to configure them correctly.
In this part of the article, for all checks we use the domain example.com, IPv4 address 1.2.3.4 and IPv6-Address 2001:db8:1:11::1 as examples. Please replace them with the real name of your website and your actual IP addresses.
Pre-requisites
Step 1. Checking the DNS provider
In the context of this article, we will need to edit DNS records multiple times. This must be done in the control panel of the current DNS provider for your domain. To do this correctly, you need to know exactly who is providing these services right now. Otherwise, the changes you make will have no effect.
Most often the role of DNS provider is performed by:
-
your hosting provider,
-
your domain registrar, or
-
your DDoS protection provider.
But this is not always the case.
You can find out exactly who is the DNS provider for your domain at the moment using the whois command. For example, let us check the domain kodu.cloud:
whois kodu.cloud | grep -i "Name Server" | awk '{print $3}'
The output will list the NS servers:
art.ns.cloudflare.com
isla.ns.cloudflare.com
That means that in this case DNS records must be edited in the Cloudflare control panel.
In many cases, you can infer who the DNS provider is from the domain name. However, this is not always so. For example, for our free DNS service, which is available to all our customers, the names look like this:
birman.nameserver.red.
rex.nameserver.red.
korat.nameserver.blue.
toybob.nameserver.blue.
In this case, please contact your hosting provider’s technical support for further clarification.
After you have definitively identified your DNS provider, log in to their control panel and go to the section for editing DNS records for your domain. Most of the changes described below will be made there. Since all interfaces differ, it is impossible to provide a universal step-by-step guide.
If you encounter difficulties at this stage, consult technical support.
After changing DNS records, cache propagation can take from 20 minutes to 24 hours. Taking into account the time required for major mail services to update your reputation, for stable mail delivery it is recommended to wait about 48 hours, although more often the situation normalizes after 2-3 hours.
Step 2. Checking for IPv6
For correct configuration, we need to know exactly whether the server has an IPv6 address. To find out, run the command:
ip a | grep inet6
If the output is approximately as follows:
inet6 ::1/128 scope host noprefixroute
inet6 2001:db8:1:11::1/120 scope global
inet6 fe80::1/64 scope link
then your server has an IPv6 address. It will be shown on the line ending with scope global up to the / sign.
Write down your server’s IPv6 address so that you can use it later.
If the output is empty, or contains only a single line of the form:
inet6 fe80::1c2:3dff:fe4a:5b6c/64 scope link
then your server does not have IPv6. In all subsequent steps, please do not use IPv6.