cPanel script to add SPF and DKIM via command line

There is a script available on every cPanel servers by default to enable the SPF and DKIM records via command line.  This will surely help when there is a need of adding the records for many accounts at the same time.

If the SPF is only for a single account, do it like the following:

 

# /usr/local/cpanel/bin/spf_installer $username

Replace $username with the actual cPanel username.

 

If the DKIM is only for a single account, do it like the following:

 

#  /usr/local/cpanel/bin/dkim_keys_install $username

Replace $username with the actual cPanel username.

 

These commands will help you to enable email authentications for single cPanel users. If you have many accounts and you want to enable SPF and DKIM for all accounts, please follow the simple for loop.

 

Here we can get the cPanel usernames from “/var/cpanel/users”. Then give that to installations scripts. Please see the sample script below:

 

for username in `ls -A /var/cpanel/users` ; do

/usr/local/cpanel/bin/dkim_keys_install $username  &&

/usr/local/cpanel/bin/spf_installer $username ; done

 

You can paste this on a text file and make it executable and run it, you are done!

  •  
  • 150 Users Found This Useful
Was this answer helpful?

Related Articles

How To Install and Use Docker on Ubuntu 16.04

Introduction Docker is an application that makes it simple and easy to run application processes...

Backup and Restore cPanel Accounts via SSH

a. How to create a backup of a cPanel Account via SSH?   1. Log-in to the SSH as the Root...

Change Main IP of the server :: Vesta Panel

If we are changing the main IP of a server installed with Vesta panel, we can use the following...

Change permissions using find command

On a Linux server, if you are in need of changing the permissions of a bulk amount of files or...

Change the time of your vps/dedi

It's very easy, you first need to remove the current time file rm /etc/localtime and replace it...