Introduction
DNS is an important component in troubleshooting email deliverability issues. There are a few DNS records that their existence and accuracy is a necessary (not sufficient - see below) requirement in making sure that the emails belonging to a specific domain, firstly are sent to the correct server, and secondly are not marked as spam by the destination mail server. These DNS records are as follows:
- MX
- rDNS/PTR (Hostname <---> IP)
- SPF
- DKIM
- DMARC
You can refer to the following article for more information about each of these records:
Checklist for Emails going to Spam
Procedure
The following command runs through every domain hosted on the server and checks all the email-related DNS records (above) for each domain to see if they are valid and have been set correctly.
alias acctinfo="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/cPanelInc/tech-acctinfo/master/acctinfo)";for i in $(awk '{print $2}' /etc/trueuserdomains); do uapi --user=$i Email list_pops 2> /dev/n | egrep "\s+email:" ; done | grep -i @|awk -F "@" '{print $2}' | uniq | while read domain; do acctinfo --mail $domain | grep -Ei "(mx|spf|dkim|dmarc|ptr)" -A 3;done
Note: If you detect a missing/misconfigured record for a specific domain and want to correct it, you need to first determine where the DNS is hosted for that domain. The following command will show you the location of the name servers that host the DNS for a domain: (change domain.com with the domain in question)
dig NS domain.com +short
whois domain.com | grep -Ei "(name server|nserver|\sns\b)"
If the DNS is not hosted on your cPanel server then you need to contact your DNS host for assistance.
Note: Please bear in mind that the existence and accuracy of these DNS record is not a sufficient condition for error-free email deliverability. There are still many other requirements that need to be met and constantly maintained in order to guarantee that your emails are sent to their targeted destination and received without any issues. Other conditions that might affect email deliverability are as follows:
- Domain reputation
- Other email-related DNS records (DNSSEC,...)
- IP not being on any blacklists (RBLs, ..)
- Internal policies of specific email providers (Gmail, Yahoo, ..)
- Limitations imposed by your host/data center/cloud provider
Needless to say, that cPanel has no control over any of these conditions, so it's recommended to contact third-party providers directly regarding any of the issues listed above.