10

Looking for some insight into this error I'm getting.

on smtpTransport.sendmail(func(err, info){})

The err variable returns this:

Error: getaddrinfo ENOTFOUND smtp.gmail.com smtp.gmail.com:465
       at errnoException (dns.js:50:10)
       at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)

and my code is:

var smtpTransport = nodemailer.createTransport({
                service: 'Gmail',
                auth: {
                    user: 'xxx@gmail.com',
                    pass: 'xxx'
                }
            });
            var mailOptions = {
                to: user.email,
                from: 'xxx@gmail.com',
                subject: 'Node.js Password Reset',
                text: ' '
            };
            smtpTransport.sendMail(mailOptions, function(err) {
            });
        }
    ], function(err) {
    });
piet.t
  • 11,718
  • 21
  • 43
  • 52
Ali Malik
  • 101
  • 1
  • 1
  • 4

3 Answers3

19

Try stop using gmail service and set it up like any other smtpTransport like the following.

var smtpTransport = nodemailer.createTransport({
    host: 'smtp.gmail.com',
    port: 465,
    secure: true, // use SSL
    auth: {
        user: 'user@gmail.com',
        pass: 'pass'
    }
});

If This does not work, your server might not be able to lookup smtp.gmail.com due to a firewall or something, to check type the following.

 nslookup smtp.gmail.com
Kalana Demel
  • 3,220
  • 3
  • 21
  • 34
1

I was facing the same issue because I wrote the wrong spelling of

stmp.gmail.com

it should be

smtp.gmail.com

var transport = mailer.createTransport({
    port : 465,
    host:'smtp.gmail.com',
})
  • I see... I'm trying to help you to better understand the rules of this site. As is, you have high probability of having a downvote... Because in the original question, clearly, the error report says: `ENOTFOUND smtp.gmail.com smtp.gmail.com:465`. Anyway, do what you think is right! For next answers, try to be more accurate, reading carefully the question. Great answers help the whole community! – pierpy May 09 '23 at 22:02
  • 1
    thankyou i made a same mistake. – Sumit Sharma Jun 14 '23 at 06:31
0

I also faced the same error with aws ses service. In my case it was wrong configuration credentials.

AWS_SES_REGION="us-east-2"
AWS_SES_ACCESS_KEY_ID=""
AWS_SES_SECRET_ACCESS_KEY=""

I updated the AWS_SES_REGION then it worked for me

  • 1
    Could you be more explicit with how you have fix, this is not really in answer. – YLR Sep 20 '21 at 14:13