How can I send direct email via nodemailer
with DKIM enabled?
I tried
const nodemailer = require('nodemailer')
const directTransport = require('nodemailer-direct-transport')
const transporter = nodemailer.createTransport(
directTransport({
dkim: {
domainName: "mydomain.com",
keySelector: "mail",
privateKey: "<generated private key>"
}
}))
require('express')().get('/test', (req, res, next) => {
console.log('sending mail')
mailer.sendMail({
from: '[email protected]',
to: '[email protected]',
subject: 'test email',
html: 'Email content'
}, (err, reply) => {
console.log('email sent')
console.log(err && err.stack)
console.dir(reply)
})
res.send('test').end()
})
I also added the public key as TXT record to my DNS panel.
The email was sent but without DKIM as I checked at http://dkimvalidator.com/results
DKIM Information: DKIM Signature
This message does not contain a DKIM Signature
Is there anyone had succeed with this? This looks a straight forward cheap way to send email without setting up SMTP server but I did not see any post on this.