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