Home > OS >  Nodemailer error (Error: queryA EREFUSED)
Nodemailer error (Error: queryA EREFUSED)

Time:11-04

sorry for my english

I am using nodemailer and when querying through the api it gives this error:

    Error: queryA EREFUSED smtp.gmail.com
        at QueryReqWrap.onresolve [as oncomplete] (dns.js:210:19) {
      errno: undefined,
      code: 'EDNS',
      syscall: 'queryA',
      hostname: 'smtp.gmail.com',
      command: 'CONN'
    }

My code:

    this.transporter = nodemailer.createTransport({
      host: "smtp.gmail.com",
      port: 587,
      secure: false,
      auth: {
        user: mygmail@gmail.com,
        pass: mypass,
      },
})

CodePudding user response:

You can use the built-in service in the Nodemailer and make your code simpler with this one.

this.transporter = nodemailer.createTransport({
  service: 'gmail',
  auth: {
    user: mygmail@gmail.com,
    pass: mypass,
  },
})

Please make sure you have disabled 2-Step verification.

CodePudding user response:

Make sure that Less secure app access is on in your Gmail account:

Less secure app access > ON

Then fix your code:

this.transporter = nodemailer.createTransport({
  service: "gmail",
  auth: {
    user: email,
    pass: password
  }
});
  • Related