Installing DomainKeys on a cPanel server
Delivering mail to yahoo and google is so hard those days. Almost every server has had this problem even if it is not used to relay spam.
Installing DomainKeys can help your server deliver “clean” emails directly to your user’s inbox.
What are DomainKeys?
Well you will find more information on this topic at: http://antispam.yahoo.com/domainkeys
Installation is simple and it’s done on a domain basis.
How to install DomainKeys on a specific domain.
- First check that you are running the latest version on RELEASE or CURRENT of cPanel 11.
- Run the script
/usr/local/cpanel/bin/domain_keys_installer username
Where username is the cPanel user.
If you get an error similar to “Domain keys are not installed on this machine.” you either are not running the latest release or current version of cPanel or you have not converted yet to maildir. Maildir conversion is required before you install DomainKeys.
You will find an article about converting to maildir on this site !
Ok, we just installed DomainKeys for a domain, but how about if we want to install it for all the domains (users)?
Well I found the solution just a few days ago on a public forum. Someone wrote a nice bash script that will parse all the cpanel users and then run the installation for each of them.
for i in `ls /var/cpanel/users` ;do /usr/local/cpanel/bin/domain_keys_installer $i ;done
Ok, but what about if we want that every new created account to have DomainKeys installed. Well this is a bit harder to do.
I recommend editing /scripts/postwwwacct and adding:
my %OPTS = @ARGV;
my $user = $OPTS{’user’};
/usr/local/cpanel/bin/domain_keys_installer $user
Now test this by creating a new account.
If you have any problems please don’t hesitate to leave a commnent here.
If you enjoyed this post, make sure you subscribe to my RSS feed!
- October 14th

















Good tutorial,Helped me a lot,thank you
This is the best article for setting up domainkeys. No technical jargon, just straight to the point.
Thanks a Million and God Bless.
[...] Read the rest of this great post here [...]
The script you posted for applying to all users should be modified to the following:
for i in `ls /var/cpanel/users` ;do /usr/local/cpanel/bin/domain_keys_installer $i; done
Without the ;done it does not execute on our servers (RHEL 4).
Thanks for the correction Andrew!
All of our server with Centos 4 & 5 OS will need to use the exact code to trigger the domainkeys installer :
#!/usr/bin/perl
my %OPTS = @ARGV;
my $user = $OPTS{’user’};
system(”/usr/local/cpanel/bin/domain_keys_installer $user”);
Hope this will helps others.
Thank you for your suggestion Sham !
#!/usr/bin/perl
my %OPTS = @ARGV;
my $user = $OPTS{’user’};
system(”/usr/local/cpanel/bin/domain_keys_installer $user”);
Doesnt seem to work with CPanel 11 Stable, though the manual domain_keys_install works fine , so does the script to update all existing domains.
The one for all “new” accounts ..just doesnt work.
What errors are you getting?
Can you make this code
my %OPTS = @ARGV;
my $user = $OPTS{’user’};
/usr/local/cpanel/bin/domain_keys_installer $user
in DNS standard template
No, I don’t see how…
Will it auto regenerate key when key will expire? or mail will just stop working?
I finally got this working with cPanel 11. What I did was create a file in the /scripts directory called postwwwacct.
Then pasted the following:
#!/usr/bin/perl
print “\nStarting install of Domainkeys\n”;
my %OPTS = @ARGV;
my $user = $OPTS{’user’};
system(”/usr/local/cpanel/bin/domain_keys_installer”, $user);
print “\nDone with install of Domainkeys\n”;
exit;
And domainkeys are being created and installed automatically. Now, if only I could figure out how to install SPF records the same way for my clients hosted accounts. There is another util in cpanel called spf_installer but I think it’s broke because it doesn’t put the domain name in the Domain field.
Any thoughts on SPF records for client sites and how to automate that? I tried editing the zone template but that doesn’t do anything.
Eric actually editing the zone template will work only for accounts that your create after that.
I am already preparing a SPF article and it should be posted in just a few days.
I found a great resource for checking your SPF and DK records. Send an email form the account you want to check to:
auth-results@verifier.port25.com
A return email will be sent with results which are very informative.
Eric I pushed the article on SPF records sooner then I initially planed it.
http://www.cpanelconfig.com/how-to/install-spf-records-on-a-cpanel-server/
Hope it helps you !
Well for some reason after doing all of the above and then sending an email to that test address it still shows as unsigned
i ran the srcipt to install domain keys on one user account and then sent an email heres ther response i get
Authentication-Results: verifier.port25.com; dkim=neutral (message not signed);
Is there some other configuration needed for this to work on a cpanel 11 server running Exim4?
DKIM and DK are different so I wouldn’t worry about that. DKIM is coming but I don’t know of any ISP really using DKIM yet. That’s at the individual message level.
DKIM IS being used for yahoo accounts, and I wish there was some way to implement this technology SOON, I know there are people out there that are having a REAL tough time getting legit newsletters to yahoo members…. you can sign all of the forms they require for bulk mailing, but DKIM seems to be even mentioned in thier bulk mailer forms, there is a comment about when do you plan on deploying DKIM
Hm.. I have:
WHM 11.2.0 cPanel 11.8.0-C15896
CENTOS Enterprise 4.5 i686 - WHM X v3.1.0
but no file /scripts/postwwwacct
Dennis, you have to create that file by hand.
ing DomainKeys on a cPanel server | cPanelConfig - cPanel server configuration guide will possibly be amazing case that you precisly covered miraculously; thank you much!
/usr/local/cpanel/bin/domain_keys_installer username
The email test always fails saying no key found. from http://domainkeys.sourceforge.net/
Any suggestions?
cPanel 11 / centOS 5
The following script finally worked!
I was trying it after creating postwwwacct and pasting the code without setting the permission to 711
#!/usr/bin/perl
print “\nStarting install of Domainkeys\n”;
my %OPTS = @ARGV;
my $user = $OPTS{’user’};
system(”/usr/local/cpanel/bin/domain_keys_installer”, $user);
print “\nDone with install of Domainkeys\n”;
exit;
DONT FORGET THIS STEP
chmod 711 /scripts/postwwwacct
THANKS FOR THIS RESOURCE !!!
Another Issue:
http://domainkeys.sourceforge.net/
There are two testing tools in there.
1. A DomainKey Policy Record Tester.
2. A DomainKey Selector Record Tester.
Tool one returns nothing for example.com
For tool 2 Enter the domain name in the following format
default._domainkey.example.com
then it returns the created key
SO IN REAL LIFE HOW TO USE THIS DOMAIN KEY FOR OUT GOING EMAILS???
IS THERE ANY STEPS TO ACTIVATE IT ANYWHERE?
Ok,so this all sets up the DNS files and everything for DomainKeys, but has anyone actually got them WORKING?
I use the Policy Record tester on sourceforge and it doesn’t find anything and I have also used a couple different test email addresses I have found :
dk@crynwr.com and autorespond+dk-nofws@dk.elandsys.com
Both of these test the DomainKeys from the originating server, however neither of these recognized the cPanel DomainKey setup.
crynwr.com reports :
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
DomainKey-Status: bad
elandsys.com reports :
DomainKeys Test: DomainKey-Signature could not be verified
DomainKeys Policy: “t=y; o=~; postmaster@viewdm.com”
DomainKeys Selector: default
“k=rsa;
p=MHwwDQYJKoZIhvcNAQEBBQADawAwaAJhAONbBbKiVKQj6fYMRUDGethoWibuRyqi2gForbkR29Dpyw27wAEAOx0cz6×4Cl6PE/leRK16+G6dGDqqiLlSGHOwNe7k4NZ2l06hPmlCD4n401TqBf78GJUAziqhg70bvQIDAQAB;”
You say add:
my %OPTS = @ARGV;
my $user = $OPTS{’user’};
/usr/local/cpanel/bin/domain_keys_installer $user
to: scripts/postwwwacct
I do not see this file and I notice others say you have to create that file. What is the proper way to do this? I can’t see having to create that file being the proper way because there is a file already creating accounts so wouldn’t creating “postwwwacct” just cause a conflict with the other file?
I have found this file on my server and it seems to be the file that creates the accounts: wwwacct
Should I paste your suggestions into that file or do I still need to create the other file?
I ran this and it work fine:
/usr/local/cpanel/bin/domain_keys_installer username
WHM 11.15.0 cPanel 11.18.3-C21703
CENTOS Enterprise 4.6 i686 on standard - WHM X v3.1.0
Hey,
This worked fine for all my users bar one, i keep getting this error:
./domain_keys_installer: usage: ./domain_keys_installer at ./domain_keys_installer line 16, line 75.
Any idea what that means?
My mistake, it means invalid username.
Account username was a typo and i was spelling it correctly.
[...] [...]
Installation de DomainKeys pour un utilisateur cPanel…
Il faut simplement utiliser la commande suivante \\ /usr/local/cpanel/bin/domainkeysinstaller username Réf.:…
Thanks much to everyone for all the work. Just made my life a LOT easier!