How to setup mail server's records in cloudflare and cpanel (DKIM and SPF) ?

How to properly set all the DNS records in cloudflare to ensure that our mail server complies with the security requirements and do not fall into spam or black lists.
How to setup mail server's records in cloudflare and cpanel (DKIM and SPF) ?
How to setup mail server's records in cloudflare and cpanel (DKIM and SPF) ?

Many times we have a website but we are not using our domain to create email addresses. If that is the case the domain main A record is already pointing to a server where the website is hosted. 

If you want to setup emails for your domain in a different server, there a few things that need to be done on the DNS. For this tutorial we will use cloudflare as our DNS manager, and a cPanel server as our mail server.

1) Add the doman to your server, in Cpanel this is done in the Domain Addons section. Simply add the domain. assign a subdomain and a path, cPanel will suggest one for you so you can go for that.


2) Identify the IP of your server because we will use it to set up a few records on the DNS, in Cpanel go back to the home page and it will be located on the right side



3) Next we need to add a few records to cloudflare so we can connect our domain to the server and also make to the have the right configuration for email deliverability. (Avoid Spam Box).

We will add 4 A records: mail, cpcontacts, cpcalendars, and webmail, all with the same IP address that we got before, make sure the cloud is turned off if using cloudflare. (cpalendars and cpcontacts are optional and used only if you will synchronize calendars and contacts).



Once all 4 are added it will look like this (plus any other records you might have):



Then we need to go back to Cpanel and get information about the DKIM and SPF records, these are standard records to ensure Email Deliverability and do not end up in the Junk mail. 

4) In Cpanel look for Email Deliverability and click on manage next to your domain.



If you notriced Cpanel had a warning "Problems Exist (DKIM and SPF)" this is because we need to install the records on the DNS.

5) Copy the Name and Value for the DKIM TXT record and paste it in Cloudflare as TXT records. Do the same for the SPF record. 

In Cloudfalre:


Once Both records are installed they will show like this



To make sure that the records were well instaled, we can go back to Cpanel and open again the Email Deliverability, if we have a VALID notification, then we successfully installed the records.

If you got to this point you have successfully setup the records and now you are ready to create new email accunots

6. From Cpanel, go to Email Accounts -> Create and select your domain, then assign a username, a password and a Storage Space. about 5Gb should be enough to start with.

The final step is to get the configuration of your emails so you can install them in Outlook or any other email application. To learn more on how to setup secure mail servers with SSL/TLS go this Article:

How to genearte a secure mail server addesses with SSL /TLS in cPanel and Cloudflare




Get a Quote

Get a Quote