How To Implement Domainkeys In Postfix Using dk-milter


Domainkeys is "DomainKeys is a method of e-mail authentication. Unlike some other methods, it offers almost end-to-end integrity from a signing to a verifying Mail Transfer Agent (MTA). In most cases the signing MTA acts on behalf of the sender, and the verifying MTA on behalf of the receiver. DomainKeys is specified in Historic RFC 4870, which is obsoleted by Standards Track RFC 4871, DomainKeys Identified Mail (DKIM) Signatures." according to the wikipedia. So why a how to on it when there is DKIM ? Well domainkeys is still actively being used and is more widely deployed than DKIM, the developer Yahoo still uses it to sign and verify mail although they are contributers to the DKIM standard.

We will be using the milter implementation of domainkeys on CentOS 5.1.



Install the rpm:

rpm -Uvh


Generate The Keys

A script to do this is provided with the rpm:

/usr/share/doc/dk-milter-0.6.0/ <selector> <domainname>

Where <selector> is anything you want to call it - I use default and <domainname> is your domain name for which you will be signing mail. This script will produce 3 files:

  • <selector>.txt - this contains the text to add to your zone file:
    default._domainkey IN TXT "g=; k=rsa; t=y; p=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJQfGTmsFzILU6ep6aSFg+WrTkaOLmoRillFNbOpNOr5Gst5H8wG9Oh2SpUytaruP/7j/eWQ8Wyz6zX2gAtzwF0CAwEAAQ==" ; ----- DomainKey default for
  • <selector>.public - It is the public key:
    -----BEGIN PUBLIC KEY-----
    -----END PUBLIC KEY-----
  • <selector>.private - This is the private key:
    -----END RSA PRIVATE KEY----

Install the private key:

mv default.private /etc/mail/domainkeys/dk_<domainname>.pem
chown dk-milt:dk-milt /etc/mail/domainkeys/dk_<domainname>.pem
chmod 600 /etc/mail/domainkeys/dk_<domainname>.pem



Add the contents of the .txt to your DNS zone file.

Add the following to your DNS zone file:

_domainkey IN TXT "t=y; o=~"

Verify your DNS configuration:



Edit the file /etc/sysconfig/dk-milter and set the following options:

# Default values
EXTRA_ARGS="-h -l -D"


Configure Postfix

Add this to the Postfix configuration file /etc/postfix/

smtpd_milters = unix:/var/run/dk-milter/dk.sock
non_smtpd_milters = unix:/var/run/dk-milter/dk.sock

Append to the existing milters if you have other milters already configured.

Start dk-milter and Restart Postfix:

 service dk-milter start

service postfix restart



To test send a mail to [email protected] you will recieve a response email with the test results. If you have a Yahoo account you can send a mail to that as well; a sample of a signed message in Yahoo is below:

Share this page:

8 Comment(s)

Add comment


From: Codechump

I followed this how to exactly... several times! I'm running CentOS 5.2
I went to the site mentioned in the rpm download link and got an RPM for v1.0.2-0 but I still can't get my out going mails signed. I'm using postfix v2.3.3 
Any suggestions?... my emails when sent to Yahoo, the headers show domainkeys=neutral(no sig) 
thanks so much...

From: John Bailo

Thanks, I think that means going the route of building my own from source!



From: victor

Hi all,

I already followed the guidelines, everything seemed fine. However, when I sent an email to a yahoo email address, we could not pass the domain authorization check and find the signature as well.

In addition, we also found that there was no any domain signature header to be appended in an email when we sent it to yahoo.

Do any linux expert know the reason? this problem really annoys us and we are very frustrated now. Please help !!!


The rpm is built for Centos/RHEL YMMV with SUSE

From: Anonymous

I tried running the rpm installation command on my openSuse 11.0 server and was told that and are needed (see below).

I'm running version .9 of these libraries to support the dkim milter.

Is a version of the dk-milter rpm that supports the latest openSSL version available?

[email protected]:~> rpm -Uvh
error: Failed dependencies: is needed by dk-milter-0.6.0-1.i386 is needed by dk-milter-0.6.0-1.i386
[email protected]:~>


Have you tested your DNS to see that it is correct ?

From: Parsa


I installed & configured all the things you said above, but when I send an email from that mail server to my email, I see in the header: DomainKeys-status: fail(bad sig).

 What happened, and how can I fix this problem?


Best Regards,

From: jack ann

when i try to install the rpm with this line command

rpm -Uvh

 i obtained :

error: skipping - transfer failed - Unknown or unexpected error
warning: u 0x9b7cc50 ctrl 0xa2d31c0 nrefs != 0 ( http)

please help me ..