Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodemailer error: self signed certificate in certificate chain

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: "[email protected]", 
      clientId: "-",
      clientSecret: "-",
      refreshToken: "-"
       })
  }
});

app.post('/send', function (req, res) {
  var mailOptions = {
      from: 'dude',
      to: '[email protected]',
      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?

like image 442
dg2903 Avatar asked Aug 03 '17 21:08

dg2903


2 Answers

Ok so it was because of the Anti-Virus software. i swear things like this make me feel like quitting.

like image 87
dg2903 Avatar answered Oct 21 '22 01:10

dg2903


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)"

like image 28
Namig Hajiyev Avatar answered Oct 21 '22 02:10

Namig Hajiyev