For those who want or need to compile and install OpenDKIM from the source code, you can follow the instructions I wrote in this article.
If you’re looking for the fastest and easiest way to get OpenDKIM running on a RedHat or CentOS system, I currently maintain the OpenDKIM package in the Fedora and EPEL repositories. This article will help you install the RPMs and then configure OpenDKIM with Postfix or Sendmail.
For general information about DKIM, check out http://www.dkim.org/. For more information about the OpenDKIM project, check out http://www.opendkim.org/.
Before you start
This tutorial assumes the following:
- You are running a “modern” RedHat-compatible Linux distro (RHEL 5/6, CentOS 5/6, Fedora, etc).
- You are running a milter-aware MTA, such as Postfix 2.3.3 or newer (do postconf -d mail_version to check) or Sendmail.
- Your Postfix or Sendmail configuration is currently working (this is very important – you don’t want to troubleshoot two programs at once).
- If you’re using Postfix, Sendmail is turned off (do service sendmail status to verify).
- If you’re using Sendmail, Postfix is turned off (do service postfix status to verify).
- The necessary commands in this tutorial are done as root. If you don’t know what that means, then you probably shouldn’t be doing this. You may be able to get away with just using sudo, but I wanted to make sure I didn’t run into any path issues, so I do it as root.
Install OpenDKIM with Yum
If you’re running Fedora 14 (or newer) or RHEL/CentOS 5 (or newer) then you can use Yum to quickly install OpenDKIM (RHEL/CentOS users must have the EPEL repositories enabled). Just do:
yum install opendkim
This will download and install OpenDKIM with all the default configuration options included below.
For those who like getting their hands dirtier, you can manually download one of my RPMs or even build your own RPM from my Source RPM, which are all available through the Fedora BuildSystem.
Generate keys for signing
Now you’re getting to the fun part. You need to generate a private and a public key for each of the domains for which you wish to sign mail. The private key is stored away from prying eyes on your server, while the public key gets published in your domain’s DNS records so that receiving mail servers can verify your DKIM-signed mail.
To make things easy, the first time you start opendkim after installing the RPM package, it will generate a default set of keys in /etc/opendkim/keys/ using your server’s domain name and the selector name “default.” However, if you want to sign for any virtual hosts or choose a different selector name than then default, you can easily generate your own keys. It really only takes a few seconds. Or, if you’re happy with the default keys, you can move on to the next step.
If you’re really hard-core, you can always build the keys manually. Or, you can use the easy script included with OpenDKIM to do it for you. I’ve manually generated enough keys in my life, so I use the script.
Before running this script, decide now what the name of your selector is going to be. A selector is a unique keyword that is associated with both keys (public and private), included in all the signatures, and published in your DNS records. For simplicity, I use the word default as my default selector. Not very creative, but it’s effective. Feel free to choose something different, but if you do, you’ll need to use it consistently throughout your setup. Also, while this should go without saying, you should use your mail domain instead of example.com throughout the following steps.
Create your keys with:
mkdir /etc/opendkim/keys/example.com /usr/sbin/opendkim-genkey -D /etc/opendkim/keys/example.com/ -d example.com -s default chown -R opendkim:opendkim /etc/opendkim/keys/example.com mv /etc/opendkim/keys/example.com/default.private /etc/opendkim/keys/example.com/default
You can do a man opendkim-genkey if you’re interested in what additional options are available when creating your keys. In this example, I used the -D (directory) option, the -d (domain) option, and the -s (selector) options. That’s all you need to get this going.
Edit the configuration files
You’re getting really close now. You need to create and/or edit four files:
- /etc/opendkim.conf – OpenDKIM’s main configuration file
- /etc/opendkim/KeyTable – a list of keys available for signing
- /etc/opendkim/SigningTable - a list of domains and accounts allowed to sign
- /etc/opendkim/TrustedHosts – a list of servers to “trust” when signing or verifying
On install, the RPM package should have created a simple /etc/opendkim.conf file on your system. Because signed outbound mail could get flagged as Spam if sent before your DNS DKIM text records are properly set up, the default operating mode set by this file is verification only (v). This means that order to sign outgoing mail, you’ll have to comment, uncomment, and configure some additional options in the configuration file. Use your favorite text editor to open /etc/opendkim.conf and make it look like this:
## CONFIGURATION OPTIONS # Specifies the path to the process ID file. PidFile /var/run/opendkim/opendkim.pid # Selects operating modes. Valid modes are s (signer) and v (verifier). Default is v. Mode sv # Log activity to the system log. Syslog yes # Log additional entries indicating successful signing or verification of messages. SyslogSuccess yes # If logging is enabled, include detailed logging about why or why not a message was # signed or verified. This causes a large increase in the amount of log data generated # for each message, so it should be limited to debugging use only. #LogWhy yes # Attempt to become the specified user before starting operations. UserID opendkim:opendkim # Create a socket through which your MTA can communicate. Socket inet:8891@localhost # Required to use local socket with MTAs that access the socket as a non- # privileged user (e.g. Postfix) Umask 002 # This specifies a file in which to store DKIM transaction statistics. #Statistics /var/spool/opendkim/stats.dat ## SIGNING OPTIONS # Selects the canonicalization method(s) to be used when signing messages. Canonicalization relaxed/simple # Domain(s) whose mail should be signed by this filter. Mail from other domains will # be verified rather than being signed. Uncomment and use your domain name. # This parameter is not required if a SigningTable is in use. Domain example.com # Defines the name of the selector to be used when signing messages. Selector default # Gives the location of a private key to be used for signing ALL messages. #KeyFile /etc/opendkim/keys/default.private # Gives the location of a file mapping key names to signing keys. In simple terms, # this tells OpenDKIM where to find your keys. If present, overrides any KeyFile # setting in the configuration file. KeyTable refile:/etc/opendkim/KeyTable # Defines a table used to select one or more signatures to apply to a message based # on the address found in the From: header field. In simple terms, this tells # OpenDKIM how to use your keys. SigningTable refile:/etc/opendkim/SigningTable # Identifies a set of "external" hosts that may send mail through the server as one # of the signing domains without credentials as such. ExternalIgnoreList refile:/etc/opendkim/TrustedHosts # Identifies a set internal hosts whose mail should be signed rather than verified. InternalHosts refile:/etc/opendkim/TrustedHosts
You can do man opendkim.conf for more information on each of the options in this file.
Uncomment the Domain option (and include your actual domain name), the KeyTable, SigningTable, ExternalIgnoreList, and InternalHosts options. Also, since you’ll be using a KeyTable, you can comment the KeyFile option.
Next, you’ll need to create the three text files that you just uncommented in your config file. First, using your favorite text editor, create an /etc/opendkim/KeyTable file that looks like this:
default._domainkey.example.com example.com:default:/etc/opendkim/keys/example.com/default
The KeyTable file tells OpenDKIM where to find your keys. Each entry in the KeyTable file is a single line for each key location (for example, all of the text in the above example should be on a single line in your file). If you’re going to use multiple keys (to sign mail for virtual domains with different keys, for example), you’ll need to create a separate line in the KeyTable file for each domain, like this:
default._domainkey.example.com example.com:default:/etc/opendkim/keys/example.com/default default._domainkey.example2.com example2.com:default:/etc/opendkim/keys/example2.com/default
Next, you need to create or edit the /etc/opendkim/SigningTable file. A default version of this file should have been installed in /etc/opendkim when you installed the RPM, so just uncomment the following line (or edit the file to include this line) so it reads:
*@example.com default._domainkey.example.com
The SigningTable file tells OpenDKIM how to use your keys, as in which senders should use which selectors for their signatures. In the above example, I’m saying that everyone (*) sending mail from the server “example.com” should use the selector named “default.” Again, for multiple domains and/or users, you’ll need multiple lines, like this:
*@example.com default._domainkey.example.com bob@example2.com default._domainkey.example2.com doug@example2.com default._domainkey.example2.com
In that example, everyone (*) sending mail from the server “example.com” can sign mail and should use the selector named “default.” But only Bob and Doug can sign mail for “example2.com” (also using a selector named default). It’s important to note that the * wildcard symbol will only work if the SigningTable option uses the refile: prefix before the filename (see the opendkim.conf documentation for more details).
Next, create an /etc/opendkim/TrustedHosts file that looks like this:
127.0.0.1 hostname1.example1.com hostname2.example1.com example1.com hostname1.example2.com hostname2.example2.com example2.com
The TrustedHosts file tells OpenDKIM who to let use your keys. Because it’s referenced by the ExternalIgnoreList directive in your conf file, OpenDKIM will ignore this list of hosts when verifying incoming mail. And, because it’s also referenced by the InternalHosts directive, this same list of hosts will be considered “internal,” and OpenDKIM will sign their outgoing mail.
IMPORTANT: Make sure you list the IP address for localhost (127.0.0.1) in the TrustedHosts file or OpenDKIM won’t sign mail sent from this server. If you have multiple servers on the same network that relay mail through this server and you want to sign their mail as well, they must be listed in the TrustedHosts file. Put each entry on its own line. An entry can be a hostname, domain name (e.g. “example.com”), IP address, an IPv6 address (including an IPv4 mapped address), or a CIDR-style IP specification (e.g. “192.168.1.0/24″).
It should also go without saying (but I’ll say it anyway) that if you’re planning to sign outgoing mail for remote hosts, your mail server should have been previously configured to allow relaying for those hosts.
Edit your MTA configuration
Now you’re ready to tell your MTA about OpenDKIM.
Postfix Users:
Telling Postfix about OpenDKIM is easy. Just add the following lines to your Postfix main.cf file:
smtpd_milters = inet:127.0.0.1:8891 non_smtpd_milters = $smtpd_milters milter_default_action = accept
If you’re running a version of Postfix prior to 2.6, you may need to add:
milter_protocol = 2
See http://www.postfix.org/MILTER_README.html#version for more info.
Don’t restart Postfix yet! You need to have OpenDKIM running first, or you’ll get errors in your maillog.
Sendmail Users:
Edit the .mc configuration file that was used to build your current sendmail.cf file. Add the following line:
INPUT_MAIL_FILTER(`opendkim', `S=inet:8891@localhost')
Then build and install a new sendmail.cf. If you don’t know how to build and install a sendmail.cf file, a quick Web search should shove you in the right direction. Explaining how to do that is beyond the scope of these instructions. I will, however, remind you that backing up your current sendmail.cf file is a good idea before you attempt any modifications.
Start OpenDKIM and restart your MTA
It’s time to fire things up! Assuming you’re using bash, do:
hash -r
to rehash your shell so you can find the init script.
Now start OpenDKIM with:
service opendkim start
You should get a message that says:
Starting OpenDKIM Milter: [ OK ]
However, if you get an error message such as:
Starting OpenDKIM Milter: opendkim: /etc/opendkim.conf: configuration error at line 6: unrecognized parameter
don’t freak out. You probably just mistyped something in one of the config files. Go to the line number of the file listed, and check your work against the example(s) in this article. Then try starting up OpenDKIM again.
Once it starts, Postfix users should refresh Postfix with:
postfix reload
and Sendmail users should do:
service sendmail restart
If everything looks good, I recommend running chkconfig on OpenDKIM to make sure it starts when you boot your server:
chkconfig opendkim on
Adding DNS Records
Now that your mail server is signing outgoing mail and verifying incoming mail, you’ll need to put some information in your DNS records to tell other mail servers how your keys are set up, and provide the public key for them to check that your mail is properly signed. Do:
cat /etc/opendkim/keys/example.com/default.txt
The output should look something like this:
default._domainkey IN TXT "v=DKIM1; g=*; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHY7Zl+n3SUldTYRUEU1BErHkKN0Ya52gazp1R7FA7vN5RddPxW/sO9JVRLiWg6iAE4hxBp42YKfxOwEnxPADbBuiELKZ2ddxo2aDFAb9U/lp47k45u5i2T1AlEBeurUbdKh7Nypq4lLMXC2FHhezK33BuYR+3L7jxVj7FATylhwIDAQAB" ; ----- DKIM default for example.com
If you manage your own DNS or have full access to your domain’s zone file, you’ll need to paste the entire contents of the default.txt file at the bottom of your domain’s zone file. If you’re using a web interface to manage your zone file, be careful that the long lines of the public key don’t wrap and create line-feed characters (or fix them if they do). Otherwise, your public key won’t work.
If you’re using GoDaddy’s Total DNS, the TXT Name would default._domainkey and the TXT Value would be everything inside the quotes (starting with v=). You can ignore the semi-colon and comments at the end.
If you’re using some other third-party DNS provider, follow their instructions for adding a new TXT Record.
You should also add another TXT Record to your zone file that reads:
_adsp._domainkey.example.com IN TXT "dkim=unknown"
This record publishes your Author Domain Signing Practices. “Unknown” is the least strict setting, and the best place to start. You can learn more and tinker with other options later, but most people just use “Unknown” for now, since ADSP is relatively new (as of the writing of this post).
And, as long as you’re messing with your domain’s zone file, now might be a good time to ensure that you already have a valid SPF Record in place. Having both DKIM and SPF in place will increase your chances of having your outgoing mail successfully delivered.
Testing Things Out
As I mentioned in my troubleshooting tips, the best way to see that everything is working on the server side is to keep an eye on your /var/log/maillog file. Do a:
tail -f /var/log/maillog
When OpenDKIM starts (or restarts), you should see lines like:
opendkim[4397]: OpenDKIM Filter: mi_stop=1 opendkim[4397]: OpenDKIM Filter v2.4.2 terminating with status 0, errno = 0 opendkim[27444]: OpenDKIM Filter v2.4.2 starting (args: -x /etc/opendkim.conf)
When you send a mail that gets successfully signed, you should see:
opendkim[22254]: 53D0314803B: DKIM-Signature header added
The best way to check that your signed mail is being authenticated and that your DNS records are properly set up is to use one of the free testing services. My favorites are:
- Brandon Checketts Email Validator
- Send a signed email to: autorespond+dkim@dk.elandsys.com
- Send a signed email to: sa-test@sendmail.net
- Send a signed email to: check-auth@verifier.port25.com
- (you can put all of the test email addresses in the To: field of a single outgoing message to test)
Each of these will tell you if things are working properly, and give you some pointers on troubleshooting if needed.
If you have a Gmail account, you can also send a signed message there for a quick and easy test. address Here’s what a signed message in Gmail will look like:
The signed by: line tells you that the message has been verified as signed by the sender (you may need to press the show details link near the top of the message to see it). I like to click the Show Original link (under the Reply drop-down on the right) to see the signed headers in all their glory.
Troubleshooting Tips
Tip 1: The best advice I can give when troubleshooting any mail issues (including OpenDKIM) is to start a second shell session in another window and do:
tail -f /var/log/maillog
while you’re starting, stopping, and/or restarting OpenDKIM and your MTA. This allows you to see more details about any errors in your configuration.
Tip 2: If OpenDKIM is starting properly and logging to your mail log, but your outgoing mail isn’t getting signed, the first thing to check is whether the default operating mode is still set to the default verification only (v) instead of sign and verify (sv) in /etc/opendkim.conf. Change the Mode to sv, restart OpenDKIM, and try sending your test message again.
Tip 3: To get the most verbose information from OpenDKIM, make sure the LogWhy option in your /etc/opendkim.conf file is uncommented and set to Yes. If your outgoing mail isn’t getting signed and you want to know why, this should tell you.
Tip 4: If you can’t get things working on your own, I recommend subscribing to the OpenDKIM-Users discussion list at http://lists.opendkim.org/. It’s a low-traffic list with very helpful and friendly members (including me!) who are happy to nudge you in the right direction.
Automating Configuration and Key Generation for Multiple Domains
If you’re hosting a large number of domains, generating keys and editing all the appropriate files can be time-consuming. The following script was submitted by a reader (Almir Duarte Jr.) to help speed up the process. Use at your own risk.
Further reading
- DKIM.org – the official site for DomainKeys Identified Mail
- OpenDKIM Project Site – the program I used to get DKIM working
- Sendmail DKIM – a detailed article from Eland Systems about DKIM. They use the dkim-milter package, upon which OpenDKIM is based. I much prefer the newer OpenDKIM, but this article explains DKIM very well and has some good tips.
- Mail-DKIM and DKIM-proxy – my first experiments with DKIM were with these tools. I never got it working quite right, but there’s lots of good info there.
- OpenSPF.org – not technically related to DKIM, but it’s another spam-fighting technique that you should be using if you’re sending email
- My OpenDKIM GitHub repo – if you’d like to mess with the SPEC file or patches that I use to create the OpenDKIM package in the Fedora & EPEL repos, knock yourself out! Please fork the “develop” branch and submit your pull requests there, as the “master” is intended only for release versions.
Good luck! Pease post in the comments with your successes, questions, or suggestions.


Thanks for providing these RPMs, it makes it much easier to install than the previous method of building from source (which I’ve been using for a while). These are excellent instruction for getting it working but there’s one error and a question. You have this at the “Edit Configuration Files” section:
/etc/opendkim/trusted-hosts
and you then reference the following (in line 61 of the conf file):
/etc/opendkim/TrustedHosts
On line 64 of the conf file you reference the dataset with a preceding “refile:” to the file name. In line 52 where you mention the KeyTable you omit the “refile:”, is this a change to the conf file or have you just missed that from a couple of those lines?
Once again, many thanks for your wok on this.
Oops, typing error. My last line should have read:
Once again, many thanks for your work on this.
Hi, Bill. Ah – that was a typo on my part. I used to recommend “trusted-hosts” but then switched to “TrustedHosts” to be consistent. I’ve updated the HowTo. Thanks for the catch!
And to answer your other quesiton, the refile: prefix is only necessary if you want to use the wildcard * symbol in your files (like I do in my SigningTable). A very early version of OpenDKIM used to support regular expressions, and the term was kept in for backward compatibility, even though it no longer technically supports regex (or needs to). I now throw the refile: prefix at all the files, because I’ve been stumped in the past when troubleshooting things that weren’t working as I expected, and didn’t notice that I’d missed the prefix. So now I always use it, and avoid the “DOH!” moments.
Im getting following error when i try to run ” /usr/local/bin/opendkim-genkey -D /etc/opendkim/keys/example.com/ -d example.com -s default”
-bash: /usr/local/bin/opendkim-genkey: No such file or directory
Let me know which step i have missed…!
Cheers…!
Do :
which opendkim-genkey
and it should tell you where it is on your server.
Getting the error
Oct 14 06:12:21 power opendkim[3408]: (unknown-jobid): no signing table match for ‘randy@somedomain.com’
Oct 14 06:12:22 power opendkim[3408]: C5D7A7070447: no signature data
*@somedomain.com default._domainkey.somedomain is in my SigningTable
somedomain=my domain. I changed it as this is public and everbdoy can view it.
Any ideas?
The “.com” is missing off your SigningTable line in this example, I’m assuming that’s in your actual signing table? Also, does your opendkim.conf file reference your SigningTable file with “file:” or “refile” in front of it? You need “refile” in order to use wildcards.
Awesome! that appears to have fixed it however it appears in my mail log the signature is not being added.
I went thew and double checked everything so what do you think is the issue?
There could be a lot of reasons. I’m assuming you followed the troubleshooting steps and set LogWhy to yes. If so, what does the log say is the reason for not signing?
I did so and it still doesn’t Display it.
Oct 14 06:34:19 power postfix/smtpd[3856]: connect from “CUT”
Oct 14 06:34:19 power postfix/smtpd[3856]: 1EBD77070447: client=”CUT”, sasl_method=LOGIN, sasl_username=”CUT”
Oct 14 06:34:19 power postfix/cleanup[3862]: 1EBD77070447: message-id=<5df0302115198ab862887b06d2d5e102@"CUT"
Oct 14 06:34:19 power postfix/qmgr[3300]: 1EBD77070447: from="CUT", size=596, nrcpt=1 (queue active)
Oct 14 06:34:19 power postfix/smtpd[3856]: disconnect from "CUT"
Oct 14 06:34:19 power dovecot: IMAP("CUT"): Disconnected: Logged out
You can see it's running tho
Oct 14 06:33:35 power opendkim[3688]: OpenDKIM Filter: mi_stop=1
Oct 14 06:33:35 power opendkim[3688]: OpenDKIM Filter v2.4.2 terminating with status 0, errno = 0
Oct 14 06:33:36 power opendkim[3830]: OpenDKIM Filter v2.4.2 starting (args: -x /etc/opendkim.conf -P /var/run/opendkim/opendkim.pid)
Boy am I’m stupid lol
I overlooked changing mode v to mode sv and it works now!
Thanks for your help!
I used opendkim under CentOS-32 and worked fine without an issue.
But I’m using opendkim under Centos-64 5.7, Postfix 2.3.3, opendkim 2.4.2 and I’m facing that Domain key =Failed.
Yahoo check = PASS, Hotmail and Gmail=Fail
brandonchecketts=Message does not contain a DomainKeys Signature
Thank you
The results are accurate. DKIM is not the same as DomainKeys. DomainKeys is outdated, and replaced by DKIM, but Brandon’s tool allows you to check both. If Brandon’s site passes the DKIM check (again, different than a DomainKeys check), then you’re good to go.
As an aside, you may want to consider upgrading your Postfix. I have a post here in my blog dedicated to building the latest version for CentOS and upgrading seamlessly.
Doesn’t Yahoo still rely heavily on DomainKeys, though? Is it possible to use opendkim to sign with DomainKeys as well as DKIM? The code suggests it’s possible, but I’m not having much luck with configuring it.
In your notes about generating keys, you may want to note that /etc/rc.d/init.d/opendkim will automatically generate keys for the host domain upon initial startup unless this variable is changed in that file:
Change
AUTOCREATE_DKIM_KEYS=yes
to
AUTOCREATE_DKIM_KEYS=NO
You do say this will happen, but this is how to prevent it from happening in case you are generating individual keys by following the steps after that.
Good point, JP. I did include that support in the spec file for the package, but didn’t mention it in this article. I’ll add it.
This script will come in handy especially if you have several domains to do. It generates the keys, then performs steps 2,3, and 4 of “Edit the configuration files”:
#!/bin/sh
domain=$1
function makekey {
domain=$1
mkdir /etc/opendkim/keys/$domain
/usr/bin/opendkim-genkey -D /etc/opendkim/keys/$domain/ -d $domain -s default
chown -R opendkim:opendkim /etc/opendkim/keys/$domain
mv /etc/opendkim/keys/$domain/default.private /etc/opendkim/keys/$domain/default
}
makekey $domain
echo "default._domainkey.$domain $domain:default:/etc/opendkim/keys/$domain/default" >>/etc/opendkim/KeyTable
echo "*@$domain default._domainkey.$domain" >> /etc/opendkim/SigningTable
Awesome little script, Ray. Thanks!
Hi Steve,
Thanks for your blog. I followed step by step process whatever you defined here. But I am getting error in my log file when I try to send mails.
opendkim[13511]: KeyTable entry for ‘default._domainkey.my_domain.com’ corrupt
Based on the error message, it’s saying something is wrong with your KeyTable. Try recreating your KeyTable and be careful not to make any typos!
When I run:
yum install opendkim
I get this repsonse:
Setting up Install Process
No package opendkim available.
Error: Nothing to do
Hi, Rick. What OS and version are you running?
RHEL 6
Thanks. And I’m assuming you have EPEL installed?
Perhaps not. How do I check?
Ah – I bet that’s it. Scroll back up and look for the link to the EPEL setup instructions in the paragraph just before the “yum install opendkim” step.
I am getting pretty close. When I run:
service opendkim start
I get – configuration error at line 2: unrecognized parameter
Line 2 is – PidFile /var/run/opendkim/opendkim.pid
I looked in the /var/run/opendkim folder and there is no opendkim.pid file.
I still have two problems. For Umask 002 I am getting an Illegal value error.
Then, when I try to start dkim, I get this error:
: dkimf_db_open(): No such file or directoryndkim.conf: refile:/etc/opendkim/TrustedHosts
Hmm… I’ve never seen that Umask issue before, so I can only assume it’s related to something on RHEL6 – and I haven’t tested this on there yet. I’ll fire up a VM and test it out.
However, the fact that you’re getting that error regarding the TrustedHosts file causes me to believe you’re missing some steps in the setup. In the “Edit the configuration files” step, it clearly states you have to create it. I’d re-read the instructions to make sure you’re not missing anything else.
I just fired up a vanilla CentOS 6 VM running Postfix 2.8.4, and then followed the instructions in this article exactly and got OpenDKIM running fine, so I’ve confirmed they work on EL6. My gut says you’re probably missing something simple in the instructions, so please go through them carefully. If you’re still having trouble, join the OpenDKIM-users mailing list and we can figure it out over there.
Thanks Steve. I joined the list and posted full details to the list.
Thanks for the fine tutorial.
A short question: When defining
"Domain example.com"
does this affect subdomains too, or we must define any subdomains explicitly?
For example, mail from tech.example.com will also be signed?
Thanks,
Nick
Subdomains are considered different domains. You can ignore the “Domain” directive if you use the SigningTable, and include all your domains and subdomains for which you wish to sign in there instead.
Related to subdomains, we have a couple older servers setup for dkim-milter so they have their own selectors (ex: william._domainkey.somedomain.com and james._domainkey.somedomain.com). I am setting up a new server with OpenDKIM, should I change the configs for all mail servers to use the same pub/private keypair and reference default._domainkey.somedomain.com ? If not how would I setup the various keytable files to handle the new server, say henry._domainkey.somedomain.com?
Just wanted to say “Thanks!” With your walkthrough, this was easy as could be.
Hi There, This guide helped me greatly – i managed to get DKIM working for all my 3 domains under postfix 2.3.3. However a recent plesk update very kindly updated my postfix to 2.8.4 and now things have changed – the DKIM signature is added via server webmail (signature works and is validated)- however emails sent from Outlook/Entourage sent through the postfix (using same authentication details) server do not get the signature added at all. I have ensured all IP addresses are add to the TrustedHosts file. Would you have any suggestions ?
Thank you very much! Awesome tutorial, I’ve set up dkim within half an hour.
I missed this part too. While this excellent article does give you the instruction to make your opendkim.conf “look like this”, it’s a bit misleading that all the other changes are explicitly mentioned. It took me a good while to figure out why my mails weren’t getting signed, though in hindsight the Mode being left at the default of “v” was obvious.
Thanks for this extremely insightful article. After setting up OpenDKIM my server e-mails are finally getting through to Gmail inboxes. Thanks!
hi,
i have installed EPEL repositories, but cant get “yum install opendkim” to work. centos 5, any idea?
Thank you
One big thanks to this great tutorial.
DKIM are working even better than expected for our emails
Excellent guide, Steve. Now have DKIM installed like a boss.
Like a BOSS!
Hi Steve I have made the guide with no problems! Its very well explained
Just that sometimes on hotmail I got DKIM pass and sometimes PermError
FAIL:
X-SID-PRA: info@mydomain.com
X-Message-Status: n:0:n
X-SID-Result: Pass
X-DKIM-Result: PermError
X-AUTH-Result: PASS
WORKING:
X-SID-PRA: info@mydomain.com
X-Message-Status: n:0:n
X-SID-Result: Pass
X-DKIM-Result: Pass
X-AUTH-Result: PASS
That test was on the fly, one mail behind other, and trying a few times it changes sometimes pass and sometimes PermError
Any idea? :/
thanks!
Sorry I have an error on the key
The k was missing on the key rsa value
v=DKIM1; =rsa; p=MIGfMA0GCSqGSIb3DQ….
But without the K sometimes hotmail return X-DKIM-Result: Pass
Now I correct it always is marked with X-DKIM-Result: Pass
Thanks
Hi Steve this is a great post! I created a simple bash script based a little off your post to automate the process a little more, espcially if you’re trying to sign lots of domains at once. Check it out here:
http://www.affjohn.com/how-to-easily-setup-opendkim-on-centos-for-dkim-key-signing/
opendkim is signing all email for all domains, even though I set it to sign only a specific domain. Any fix for this?
Really great tutorial, thanks a ton for putting it up. It worked perfectly, I just had to also change the /etc/sysconfig/opendkim AUTOCREATE_DKIM_KEYS=NO like JP says above to keep it from generating keys on startup. Hotmail and gmail are both passing dkim now, and I’m going to check everybody else now. Thanks again!
Hi Steve, excelent tutorial, But i can’t get signed my emails, i did everything step by step and i have no errors or missing any configuration, i have recheked some times. My emails are not signed yet, i add the TXT records yesterday and is not correct 24 hours after. What i can check to get this solved?
I apreciate your help.
Hello. Great article, thanks for the tutorial . I’m newbie with DKIM and postfix but with this excellent tutorial mails was signed at the first run!!
Hello.
Thank you. Great, great, great… This is only one good guide.
SigningTable
*@
correct any my problems
Thanks Steve. Good Job
Steve,
This is a wonderful guide, and I’m now using DKIM correctly and it’s working in all cases except one. Our mail server runs a script to deliver a mailing list to our clients. How it works is that it generates an email file on disk, and then runs “cat /path/to/tempfile | sendmail -t -fmailinglist@domain.com” so that the sendmail script parses the tempfile for addresses to send the email to. The headers of the email contain the recipients in a bcc header.
The problem appears to be that the sendmail script does not connect to the smtp server (postfix) via TCP connection, EG: 127.0.0.1, and so emails processed this way do not appear to be getting signed. Any idea how we can add local file sockets to the TrustedHosts file?
Server Config:
CentOS 6
Postfix
opendkim-2.7.3-2.el6.i686 from epel
TrustedHosts
127.0.0.1
localhost
192.168.254.2
With this config, dkim signatures appear in emails sent from 192.168.254.2 using sendmail -t, but not when using sendmail -t on the mail server itself. Also, the email headers as received by the recipients doesn’t contain an expected header like:
Received: from ourserver (ourserver.domain.com [127.0.0.1])
by ourserver.domain.com (Postfix) with ESMTP id 865A0C03C9
for ; Tue, 8 Jan 2013 02:02:42 +0000 (UTC)
It’s this missing header which makes me suspect that it’s not matching TrustedHosts entry.
Cause found, original post can be deleted. postfix main.cf change from
non_smtpd_milters = $smptd_milters
# to
non_smtpd_milters = $smtpd_milters
# note $smptd_milters should be $smtpd_milters
Hello, thank you for your post, it is really helpful and well explained. I followed all those step, but my email still don’t integrate the dkim signature, i don’t know why. when i test sending email, i get this header.
Return-Path:
X-Original-To: best@www.brandonchecketts.com
Delivered-To: spamapp@yen.roundsphere.com
Received: from iituness.com (iituness.com [192.162.68.128])
by yen.roundsphere.com (Postfix) with ESMTP id 2E7CA3A38009
for ; Sat, 12 Jan 2013 12:55:15 -0500 (EST)
Received: from iituness.com (localhost [127.0.0.1])
by iituness.com (8.14.4/8.14.4) with ESMTP id r0CHtEsp032049
for ; Sat, 12 Jan 2013 20:55:14 +0300
Received: (from root@localhost)
by iituness.com (8.14.4/8.14.4/Submit) id r0CHtE2a032047
for best@www.brandonchecketts.com; Sat, 12 Jan 2013 20:55:14 +0300
Date: Sat, 12 Jan 2013 20:55:14 +0300
From: “me@iituness.com”
Message-Id:
Subject: Testing
i think the error is that root@localhost is the sender of the email, i don’t know how to change it.
can you help me?
Steve, first thank you very much for your nice tutorial.
Basically I think my setup is runnig, but I’m experiencing problems with the DNS record. While doing the
cat /etc/opendkim/keys/example.com/default.txt
I receive the output as follows:
default._domainkey IN TXT “v=DKIM1;=rsa; p=MIGfMA0G
Since my messages do not appear as signed somewhere else and http://dkimcore.org/c/keycheck tells me “This is not a good DKIM key record”, I strongly believe something is going wrong. Unfortunately I have no clue what this could be, everything has been done as provided by you.
Thanks a lot in advance!
Hi,
I have written a small script to try to automate this process in the case where we have a certain amount of domains hosted.
BE CAREFUL!!!
https://gist.github.com/4691912
(scripted edited out of comment and transferred to Gist)
Thanks, Almir! I’m sure this will come in useful for admins with lots of domains. I’ll mention it in the main article.
I followed these steps carrefully, but in the end I always get DKIM fail.
==========================================================
Summary of Results
==========================================================
SPF check: pass
DomainKeys check: neutral
DKIM check: fail
Sender-ID check: pass
SpamAssassin check: ham
Authentication System: DomainKeys Identified Mail (DKIM)
Result: DKIM signature confirmed BAD
Description: Unrecoverable error during processing; signature data cannot be verified
Reporting host: services.sendmail.com
More information: http://dkim.org/
Sendmail milter: http://opendkim.org/
I’m using CentOS 6.3 (x64), Postfix 2.6.6 and MailScanner 4.84.5.
Could you help me?