DomainKeys (DKIM) and SPF records are becoming a common, and annoying, demand among email providers, mainly Yahoo and Hotmail. In short, both are methods of email authentication designed to verify email integrity, by linking a sender to a specific server or hostname. In other words, DomainKeys and SPF records specify what servers can send email on behalf of a domain name.
This how to describe how to add domainkeys and SPF (Sender Policy Framework) records on CPanel Servers. Whenever you create a domain on CPanel server using WHM, it wont add domainkeys and SPF records for particular domains. To add domainkeys and SPF records please use following steps.
Add the following at the bottom of the file:
Or you can use another method
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:
Configure Exim
Open /etc/exim.conf and near the top, add the following lines:
Then scroll down until you see these lines(line nuber 1518):
Replace this with:
Run chattr +ia /etc/exim.conf and restart the exim.
This how to describe how to add domainkeys and SPF (Sender Policy Framework) records on CPanel Servers. Whenever you create a domain on CPanel server using WHM, it wont add domainkeys and SPF records for particular domains. To add domainkeys and SPF records please use following steps.
How To Install DKIM and SPF in cPanel
Adding Domain Keys for a Single User
/usr/local/cpanel/bin/dkim_keys_install username
Adding Domain Keys for All Users
for user in `ls /var/cpanel/users`; do /usr/local/cpanel/bin/dkim_keys_install $user; done
Adding SPF Records for a Single User
/usr/local/cpanel/bin/spf_installer username
Adding 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
vi /scripts/postwwwacct
Add the following at the bottom 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 for adding SKIM / SPF Records to 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
Or you can use another method
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.