PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, November 9, 2022

[FIXED] How to send direct email with DKIM enabled with nodemailer?

 November 09, 2022     dkim, email, node.js, nodemailer, smtp     No comments   

Issue

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: 'support@mydomain.com',
    to: 'pmmEoRzqH5EyTO@dkimvalidator.com',
    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.


Solution

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



Answered By - transang
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing