nodemailer error: self signed certificate in certificate chain

Viewed 8104

I googled this but could not find an answer for my problem. here is my code

var xoauth2 = require('xoauth2');

var transporter = nodemailer.createTransport({
  service: "Gmail",
  auth: {
    xoauth2: xoauth2.createXOAuth2Generator({
      user: "dude@gmail.com", 
      clientId: "-",
      clientSecret: "-",
      refreshToken: "-"
       })
  }
});

app.post('/send', function (req, res) {
  var mailOptions = {
      from: 'dude',
      to: 'derp@gmail.com',
      subject: 'Email Example',
      text: 'username: ' + req.body.firstname,
      attachments:[
        {
          filename: req.files.myfile.name,
          content: new Buffer(req.files.myfile.data,'utf-8')
        }
      ]
  };

  transporter.sendMail(mailOptions, function(error, info){
    if(error){
      console.log(error);
      res.send(error);
    } else {
      console.log('Message sent!!');
      res.send('sent');
    }
  });
});

i used to have this problem back when i did not use oauth2, now that im using it i thought it would go away but it didnt. what am I doing wrong here?

2 Answers

Same was with me. My antivirus is AVG. Instead of turning the antivirus off in AVG you can go to Settings>Components>Email Shield>Customize>SSL Scanning and uncheck "Scan SSL connections".

In Avast Go Settings/Protection/Core Shields/Configure shield settings/Mail Shield and uncheck "Scan outbound emails (SMTP)"

Related