Emails not getting delivered to inbox of yahoo, hotmail and gmail is a common problem that many users face due to different reasons, many times its IP reputation or the email activity on the shared environment.

spf and domainkeys can help with this situation to get the emails delivered directly to inbox. cPanel documentation has good definition for both of these terms :

DomainKeys An email authentication method that attempts to verify that a message actually came from the domain it appears to have come from.

SPF (Sender Policy Framework) A feature that allows a recipient server to verify that an email message has really been sent from the domain specified in the From: field. Enabling SPF can prevent your server from receiving replies to spam that has forged your domain name as part of the sender’s address. SPF only works if both the sending and receiving mail servers have SPF enabled.

To enable domain keys and spf cPanel provides built in scripts which can be used.

For root level handling below scripts are available which cna be used.

/usr/local/cpanel/bin/domain_keys_installer CPANELUSER
/usr/local/cpanel/bin/spf_installer CPANELUSER

Where CPANELUSER will be the actual cPanel user of the related account/domain.

Similarly below scripts can be used to uninstall/remove DomainKeys and SPF :

/usr/local/cpanel/bin/domain_keys_uninstaller CPANELUSER
/usr/local/cpanel/bin/spf_uninstaller CPANELUSER

For providing the option of enabling/disabling these at User level i.e. for clients to do it from their cPanel, the ‘Email Authentication‘ option will need to be enabled in WHM at below link :

WHM >> Packages >> Feature Manager

If you want the accounts to be created with both DomainKeys and SPF enabled by default then you can add this to /scripts/postwwwacct script. You will need to follow the syntax and format that cPanel requires for any post account creation setups in this script.

Other than adding these, follow some simple tips below for getting your email to third party providers Inbox instead of spam/junk folders :

– Make sure to create a proper RDNS/PTR entry for the main IP or the IP you are using for Exim in case its different
– Set the catchall address to ” :fail: ” ( without quotes )
– Reduce/Avoid setting up forwarders from the domain on the server/vps to third party provider emails

Have a nice Email experience !

Tags: , , , , ,

1 Comment on How To : “Setting up spf and DomainKeys records on cPanel servers”

  1. Tamo says:

    Keep up the good work. I know about domain keys and SPF records but I’ve always been doing it manually. Cheers for pointing out those scripts, Not come across that before. :)

Leave a Reply to Tamo Cancel reply