Attach DKIM signature to domain name like sendgrid

In this post I am sharing a trick in which we will assign DKIM signature like Sendgrid do.The method is not excatly same but the task can be accomplished.I was getting “no signing table” error.Because of which DKIM-Signature was not attaching in recipient’s email header. My application mailer was using gmail id in from: field .In mail log I found “no signing table for sharadabcdbla@example.com”.It means OpenDKIM was looking for example.com in configuration file which do not exist. Because I was not hosting example.com in my mail server because I do not have its DNS Configuration access.

But we have set the Return-Path to our Mail server domain.Hence SPF record has pass status.

First of all lets have a brief introduction about DKIM .

What is DKIM

Abberviation of DKIM is DomainKeys Identified Mail. DKIM provides a method for validating a domain name identity that is associated with a message through cryptographic authentication.DomainKeys Identified Mail (DKIM) lets an organization take responsibility for a message that is in transit.
When you open a header of email,you can see the DKIM-Signature and DKIM status.
DKIM status should be pass (It should not be neutral/fail etc)

As we know, when we send email by using sendgrid. It attaches its DKIM Signature.
Lets have a look in below given sample

dkim=pass header.i=@sendgrid.info
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info;
h=content-type:mime-version:subject:from:to:cc:sender; s=smtpapi;
bh=qyasIP3TbJY0OeIFH1qAOq0CudM=; b=fryTYgqYlWbT/L+kauLTxpw3jvKQv
36lSF9lOBO1+UZnYKxbcGut49MWUMQ9Htacc8MTUJD+ZvTo7w9hK97wupwG0V8YF
CB7qd3iomR0i2jFrERLBSHr65SLGc75T2qYW5zm7Bm9GqnMgp8UM3+yzTG4mfo/C
VislQo5IOnCDGc=
DomainKey-Signature: a=r

In above sample, you can see the dkim status is pass.And DKIM-Signature has sendgrid domain (d=sendgrid.info)

Now here scenario is, When our application Server send email to our own hosted Mail Server(Postfix+opendkim) . The DKIM should be in pass status. As well as the DKIM signature should have domain name which resembles to our mail server.

Description of our Mail Server :

DNS A Record : sharadchhetri.com
DNS MX Record : mail.sharadchhetri.com
The Opendkim’s SignatureTable file has given below configuration

*@sharadchhetri.com default._domainkey.sharadchhetri.com

Application Using email id : noreply@sharadchhetri.com . With this email id,I was authenticating the account. We have set noreply@sharadchhetri.com in Return-Path in mailing code.

How I attached my mail server domain name in DKIM signature , to the email header of sharadabcdbla@example.com

Configure SigningTable file

(1) In case ,if you want to attach DKIM signature for a particular domain

Edit the SignatureTable file in /etc/opendkim directory
Add below given lines and replace the domain name as per your information

*@example.com default._domainkey.sharadchhetri.com


(2) In case ,if you want to attach DKIM signature for all domain

* default._domainkey.sharadchhetri.com


Restart the opendkim

/etc/init.d/opendkim restart

Restart the postfix

/etc/init.d/postfix restart

1 thought on “Attach DKIM signature to domain name like sendgrid”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.