Install DKIM and SPF in cPanel

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:

#!/usr/bin/perl

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:}}
DKIM_PRIVATE_KEY = ${if exists{DKIM_FILE}{DKIM_FILE}{0}}

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

    remote_smtp:
    driver = smtp

Replace this with:

remote_smtp:
    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.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

mail: command not found cpanel server

If you got an error mail: command not found on a new install when running a script that emailed...

Manage Exim Mail Queue Manager in WHM

The Mail Queue Manager allows you to view, delete, and attempt to deliver queued messages that...

Mailman Error Mailman Bug | Internal Server Error

Are you getting Internal server error while accessing mailing list? Mostly it will be displayed...

Convert MBox accounts to MailDir

MBox is the original and ancient format for storing mail on Unix systems, it consists of a single...

Email server troubleshooting

Email / Exim server troubleshooting techniques. You can use the following email server...

Powered by WHMCompleteSolution