title: Error: connect ECONNREFUSED 142.251.10.108:465 Nodemailer ejs render | localhost
body: <p>Thank you for your valuable time.
  I was using nodemailer to send mail on Gmail account.</p>
  <pre><code>const nodemailer = require('nodemailer');
  var ejs = require(&quot;ejs&quot;);
  
  const viewpath = __dirname + '/template/';
  var transporter = nodemailer.createTransport({
      service: 'gmail',
      host: 'smtp.gmail.com',
      port: 465,
      secure: true, // use SSL
      auth: {
          user: 'sample@gmail.com',
          pass: 'passs'
      }, 
  });
  
   ejs.renderFile(viewpath + &quot;test.ejs&quot;, { name: req.body.first_name }, function (err, data) {
   if (err) {
     console.log(err);
   } else {
    var mainOptions = {
      from: 'sample@gmail.com',  // sender address
      to: 'mymail@gmail.com',   // list of receivers
      subject: 'Subject',
      html: data
    };
    transporter.sendMail(mainOptions, function (err, info) {
     if (err) {
      console.log(err);
     } else {
      console.log('Message sent: ' + info.response);
     }
   });
  }
  });
  </code></pre>
  <p>Got error in console</p>
  <p>[Error: connect ECONNREFUSED 142.251.10.108:465
  at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) {
  errno: -4078,
  code: 'ESOCKET',
  syscall: 'connect',
  address: '142.251.10.108',
  port: 465,
  command: 'CONN'
  }][1]</p>