Scripting

Enable DKIM and SPF for all accounts in cPanel

The SPF and DKIM records are a type of Domain Name Service records. This post helps you to enable DKIM and SPF for all accounts in cPanel with a script. The purpose of these records is to prevent spammers.

The SPF (Sender Policy Framework) identifies which mail servers are permitted to send email on behalf of your domain.So it will prevent spammers from sending messages with forged “From addresses” at your domain.

DKIM (DomainKeys Identified Mail) is an email validation system designed to detect email spoofing by providing a mechanism to allow receiving mail exchangers to check that incoming mail from a domain is authorized by that domain’s administrators and that the email (including attachments) has not been modified during transport.

We can simply enable the SPF and DKIM records from cPanel (Home >> Mail >> Email Authentication). If you need to enable DKIM and SPF for all accounts in cPanel, it is not possible to manually enable them via cPanel. In that case you can use the following script.

To Enable:

 
cat /etc/trueuserdomains | cut -d: -f2 >> /root/users.txt
for i in `cat /root/users.txt` ;do /usr/local/cpanel/bin/dkim_keys_install $i ;done 
for i in `cat /root/users.txt` ;do /usr/local/cpanel/bin/spf_installer $i ;done

To Disable:

Also, you can disable the DKIM and SPF records on all accounts in cPanel using the following script.

 
cat /etc/trueuserdomains | cut -d: -f2 >> /root/users.txt
for i in `cat /root/users.txt` ;do /usr/local/cpanel/bin/dkim_keys_uninstall $i ;done 
for i in `cat /root/users.txt` ;do /usr/local/cpanel/bin/spf_uninstaller $i ;done

That’s it!

Also Read: URL to Delist IP from Hotmail Outlook blacklist

If you like the post and wish to receive more articles from us, please like our FB page: If you like this post and wish to receive more articles from us, please like our FB page: Button

Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.

For more details on our services, please drop us an E-mail at info@grepitout.com