If you’re like me, you rely on e-mails from your VPS server to inform you about important activities like backups, updates, and expiring SSL certificates. If you properly set up notifications, you minimize your time logging into your VPS and checking stuff. So it’s extremely important to ensure that these e-mails reach you on time. However, many e-mail providers like Gmail and Outlook don’t accept e-mails from IP addresses and e-mail IDs without certain DNS entries.
So this quick tutorial will help you insert the right DNS entries so that your domains can send mail without going to spam.
Accessing Your DNS Records
A good number of people use the same company for their web hosting and their domain management. If you’re one of them, you should have an interface in your web hosting admin screen for changing your DNS records. Personally, I point my nameserver to Cloudflare and manage the DNS records from there. If you use Cloudflare as well, you’ll have to log into the dashboard and make the necessary changes.
Allowing Someone to Send Mail on Your Behalf
Setting up, configuring, and maintaining an e-mail server on your own can be a harrowing task. You must deal with storage, spam, mail queues, and all kinds of hassles. As a result, many people outsource their e-mail functionality to 3rd parties like Google that handle the e-mail on their behalf instead. Earlier, I’d written about Cloudflare’s free e-mail routing that catches e-mails sent to an address and forwards them to another e-mail address of your choosing.
But this can be dangerous. After all, if a 3rd party can send e-mails on your behalf, what’s to prevent someone else from spoofing an e-mail on your behalf? And that’s why we need SPF records.
Adding an SPF Entry to Your DNS Records
An SPF DNS entry informs those who receive e-mails which parties are authorized to send e-mails on your behalf. It’s easy for anyone to spoof the “From” address on an e-mail message, but they can’t hide their IP address or the server from which the e-mail was sent. An SPF record is a compact way of informing the world which IP addresses and servers are allowed to handle e-mail on your behalf.
An SPF record has a format that looks like this:
v=spf1 ip4:xxx.xxx.xxx.xxx include:firstdomain.com include:seconddomain.com ~all
Replace xxx.xxx.xxx.xxx with the IP address of the servers you use to send your mail. Replace firstdomain.com and secondomain.com with the domains that your VPS server uses to send e-mail. If you use a 3rd party service to send e-mail, check out their documentation to find out what you should include here. It’ll be different for each provider.
For example, to use Cloudflare routing, I have to use the following address in the SPF record: _spf.mx.cloudflare.net like this:
As you can see, I’ve also included the domains that my server uses to send me notification e-mails of server events. This ensures they don’t get caught in Google’s and Outlook’s spam filters.
Mail DNS Entries Can be Confusing
My biggest problem is that I do my research on a particular issue and then forget about it afterward. Later, when I need to change something, I must re-learn it all over again! SPF and DNS records for e-mail are no different. Luckily, these don’t need to be modified once you have the correct DNS entries unless you change your e-mail provider. Hopefully, you found this article useful!
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Leave a Reply