0

I am newbie to nodejs and learning by implementing some examples.I am trying to send an email using nodemailer using below code:

    var smtpConfig = {
    host: 'smtp.gmail.com',
    port: 465,
    secure: true, // use SSL
    auth: {
        user: 'xxx@gmail.com',
        pass: 'xxx@a'
    }
  };

   var transporter = nodemailer.createTransport(smtpConfig);

   // setup e-mail data with unicode symbols
   var mailOptions = {
      from: '"Fred Foo ?" <xxx@gmail.com>', // sender address
      to: 'xxx@gmail.com', // list of receivers
      subject: 'Hello ✔', // Subject line
      text: 'Hello world ?', // plaintext body
      html: '<b>Hello world ?</b>' // html body
   };

   // send mail with defined transport object
   transporter.sendMail(mailOptions, function(error, info){
      if(error){
        return console.log(error);
      }
      console.log('Message sent: ' + info.response);
       });
     }

I am getting following error when i run:

enter image description here

Can anyone let me know where am i doing wrong.

EDIT:

Verified connection configuration using below code:

// verify connection configuration
transporter.verify(function(error, success) {
   if (error) {
        console.log(error);
   } else {
        console.log('Server is ready to take our messages');
   }
});

The verification returns error- Error: connect ECONNREFUSED

Checked these-

  • Not a firewall issue, as it was disabled
  • Enabled- Access for less secure apps

Thanks, WH

WonderHeart
  • 678
  • 10
  • 28
  • @JohannesMerz- Its not firewall issue in my case as mentioned in that post – WonderHeart Oct 04 '16 at 16:05
  • @nhouser9, Andre Figueiredo, Vini.g.fer, Coatless, Aditya Vyas-Lakhan - Please , can someone provide me what should be the resolution for this issue if this is marked as duplicate, as i mentioned in my earlier comment that firewall couldn't be an issue since its disabled already. – WonderHeart Oct 05 '16 at 18:39

0 Answers0