0

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.

1 Answer 1

0

Finally, I figured out my own solution.

nodemailer is big project but it looks lack of maintainer. Non-bug-report issue is closed by default.

I switched to sendmail then everything works like a charm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.