Add SPF Records and DKIM Keys in cPanel

For Shared Hosting and Reseller Hosting accounts from Rad Web Hosting, the DKIM keys will be automatically generated for domains associated with the account.

This article provides various methods for adding DKIM keys and SPF records to cPanel domains. Root-Level WHM server access is required.

Add DKIM Keys for a Single User

Login as root user via SSH and run the following command:

/usr/local/cpanel/bin/dkim_keys_install username

Replace "username" with the account's username.

Add DKIM Keys for All Users

for user in `ls /var/cpanel/users`; do /usr/local/cpanel/bin/dkim_keys_install $user; done

Add SPF Records for a Single User

As root user, run the following command:

/usr/local/cpanel/bin/spf_installer username

Replace "username" with the account's username.

Add SPF Records for a All Users

for user in `ls /var/cpanel/users`; do /usr/local/cpanel/bin/spf_installer $user; done

Setup Server to Create DKIM / SPF Records on New Account Creation

Edit the /scripts/postwwwacct file using your preferred text editor, such as:

nano /scripts/postwwwacct

Add the following at the end of the file:

print "\nInstalling DKIM / SPF Records for $name ...";
system("/usr/local/cpanel/bin/dkim_keys_install $name");
system("/usr/local/cpanel/bin/spf_installer $name");

Shell Script to Add DKIM / SPF Records for All Users:

#!/bin/bash
for user in `ls /var/cpanel/users`
do
echo "Installing SPF Record for $user...";
/usr/local/cpanel/bin/spf_installer $user;
echo "Installing DKIM Record for $user...";
/usr/local/cpanel/bin/dkim_keys_install $user;
done

Conclusion

You now know how to add SPF records and DKIM keys in cPanel.

  • spf records, dkim keys, email authentication, spam protection
  • 15 Users Found This Useful
Was this answer helpful?

Related Articles

Video: Create Email Address in cPanel

This video tutorial demonstrates how to create an email address using cPanel Shared Hosting...

How to Disable Simplified Account Creation in Outlook 2016

Summary When you configure an Office 365 account in Outlook 2016, you see the...

Guide to Domain EPP Status Codes

EPP Status Codes are used by the Domain Registry to signify the status of a particular domain...

Addon Domain Vs Alias Domain

The table below lists some key characteristics of Addon Domain and Alias Domain....

Video: How to Enable Spam Protection in cPanel

This video tutorial provides Step-by-Step instructions for enabling spam protection in cPanel...