How To Setup An SPF DNS Record With Zoho Mail In A VPS

Using a VPS to host your domain(s) can give enormous advantages over using shared hosting, but can sometimes be annoying to configure. Zoho mail is a fantastic free service which can host your domain’s emails for free even if your domain is hosted on a VPS. For example, if you owned the domain example.com, you could use the email address [email protected] or any other email address you wanted on that domain with Zoho. This article will discuss how to setup an SPF DNS Record with Zoho mail in a VPS.

What is SPF?

SPF is a way to detect email spoofing which cuts down on spam. Unfortunately, big email companies like Google (gmail.com) and Yandex (mail.yandex.com) and others will sometimes flag email from your domain hosted on Zoho as spam if you don’t have an SPF or DKIM record set up.

I have used Zoho mail for a long time with a domain, but sometimes would send email to people from my email hosted there, only to find out they never read my emails due to it going into their spam folders. It was only recently that I realized that it was because I didn’t set up an SPF DNS record.

Assumptions For This Article

I am going to assume that you already have a domain hosted on a VPS with the main DNS records (such as A records) setup for the domain already setup in Linux using bind9. In addition, I am going to assume that you already have setup and verified a Zoho mail account and are hosting your email with Zoho, but haven’t already setup SPF and/or DKIM. (Though, I plan to write a full series of articles on setting DNS from scratch soon.)

Steps For Setting Up SPF Record For Zoho Mail

Step 0: Login into your VPS

Step 1. Find your DNS config file

Go to /etc/bind/ and find the config file for your domain’s
for example, for this site, I would do
cd /etc/bind/
ls
and I would see that the appropriate config file is db.linuxwebdevelopment.com

Of course yours will be different. For example, if your domain is example.com, your config file should be db.example.com

Step 2: Edit file and make sure MX records are correct

now edit the file with sudo (or without sudo if you are already logged in as su)
sudo vim db.example.com

(remember to change db.example.com with your actual domain name and extension)

Even though I assume you already are hosting your email with Zoho, make sure your MX records look something like this:

@ IN MX 10 mx.zoho.com.
@ IN MX 20 mx2.zoho.com.
@ IN MX 50 mx3.zoho.com.

Step 3: Add SPF record

Now for the SPF records

Simply add this line, exactly as it is written

@ 600 TXT "v=spf1 include:zoho.com ~all"

Now save the file.

Step 4: Restart Bind9

Next, we will restart bind for the changes to take effect.
sudo service bind9 restart
That is all you need to do to setup SPF for Zoho mail.

Finally, you should verify that you in fact correctly setup the SPF record. I recommend using these 2 sites to verify the SPF is in fact setup correctly:
mxtoolbox.com/spf.aspx
kitterman.com/spf/validate.html

Simply type in your domain, such as example.com into those links to see that your SPF is setup correctly. If they give you green check marks or a message with something like “SPF record passed validation test with pySPF (Python SPF library)!”, you know that you setup SPF correctly.

*Quick note about a bug in Zoho mail. This article on Zoho forums talks about a bug in Zoho mail in which SPF is actually setup correctly, but Zoho incorrectly gives the message “SPF entries in your domains DNS are not configured to match with Zoho & Google Gmail”. If you use the aforementioned tools to test the SPF, and those sites say SPF correctly setup, you can probably ignore the Zoho error message, if you do get it.

What did you think of this article. Have any questions? Let’s discuss this in the comments below.

Posted on Categories DNS, Email

Leave a Reply

Your email address will not be published. Required fields are marked *