The following scripts are used to enable DKIM and SPF records

   /usr/local/cpanel/bin/dkim_keys_install <username>

  /usr/local/cpanel/bin/spf_installer      <username>

If you wish to add DomainKeys and SPF for all Cpanel users on your server, execute following command.

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

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

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

For new users:
cPanel already though of that, and has options to create hooks for when after an account is created. To set up the server to automatically create an SPF record and DomainKey for new accounts, edit/create /scripts/postwwwacct and paste in the following code:


my %OPTS = @ARGV;

$ENV{USER} = “$OPTS{‘user’}”;
system q(/usr/local/cpanel/bin/dkim_keys_installer $USER);
system q(/usr/local/cpanel/bin/spf_installer $USER);

Configure Exim

Open /etc/exim.conf and near the top, add the following lines:

DKIM_DOMAIN = ${lc:${domain:$h_from:}}
DKIM_FILE = /var/cpanel/domain_keys/private/${lc:${domain:$h_from:}}

Then scroll down until you see these lines(line nuber 1518):

    driver = smtp

Replace this with:

    driver = smtp
    dkim_domain = DKIM_DOMAIN
    dkim_selector = default
    dkim_private_key = DKIM_PRIVATE_KEY
    dkim_canon = relaxed
    dkim_strict = 0

Run chattr +ia /etc/exim.conf and restart the exim.


Get Free cPanel Knowledge Base

Thank you for subscribing.

Something went wrong.

4.50 avg. rating (90% score) - 8 votes