Add SPF Records and DKIM keys in cPanel

This article provides various guides to add DKIM keys and SPF records to cPanel users. Root-Level cPanel server access is required.

Add DKIM Keys for a Single User

As root user:

/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:

/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

As root user:

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

Was this answer helpful?

 Print this Article

Also Read

How to Create a Subdomain in cPanel

A subdomain is a subsection of your website that exists as a subdirectory in your public_html...

How to Flush DNS Cache

Flushing your DNS cache can be useful when the information about a domain you hold is outdated,...

Removing cPanel Accounts with /scripts/removeacct Script

The /usr/local/cpanel/scripts/removeacct script terminates cPanel accounts from the command line....

How to Flush DNS Cache in Windows 10

Flushing the DNS resolver cache can help resolve DNS related problems in Microsoft Windows 10....

Using .htaccess File to Block IPs

You may block access to your website from specific IP addresses using .htaccess file. You need to...