Signing Email Using DKIM in Node.js

I am writing a Nodejs application that should send email. So far, I have used Postfix in conjunction with a Nodejs module called Nodemailer to send email through Amazon SAS.

Postfix processes the DKIM subscription, but now I want to get rid of the postfix and just use Nodemailer to send email through Amazon SAS.

My only problem now is finding a way to sign emails in Nodejs. I was thinking of running the opendkim command using "exec" in node, but couldn't figure it out. From the search there are also no modules for this.

Can someone help me with this?

+7
source share
2 answers

The latest version of Nodemailer supports DKIM signing out of the box, also tested with SES.

var transport = nodemailer.createTransport("SES", { AWSAccessKeyID: "AWSACCESSKEY", AWSSecretKey: "AWS/Secret/key" }); // all messages sent with *transport* are signed with the following options transport.useDKIM({ domainName: "example.com", keySelector: "dkimselector", privateKey: fs.readFileSync("private_key.pem") }); transport.sendMail(...); 
+8
source

you can find in https://gist.github.com/2198497 an implementation that I developed to send dkim signatures sent via SES. He is very inspired by the php implementation by Ahmad Amarulla, found here: http://code.google.com/p/php-mail-domain-signer/ . I know well that the code is far from clean, but it should help you get started. Emails sent through it are considered valid gmail and yahoo. Do not be shy if you have questions / cannot make it work.

+5
source

All Articles