1

I am trying to use nodemailer in my application and i am using hostinger to host my emails when i try to connect nodemailer using this code to the hostinger email which is found on the nodemailer docs

const nodemailer = require("nodemailer");
nodemailer.createTestAccount((err, account) => {
  // create reusable transporter object using the default SMTP transport
  let transporter = nodemailer.createTransport({
    host: "smtp.hostinger.com",
    port: 465,
    secure: true, // true for 465, false for other ports
    auth: {
      user: "EMAIL", // generated ethereal user
      pass: "PASSWORD", // generated ethereal password
    },
  });
  transporter.verify(function (error, success) {
    if (error) {
      console.log(error);
    } else {
      console.log("Server is ready to take our messages");
    }
  });
});

so i can send emails but I am getting this error

  Client network socket disconnected before secure TLS connection was established
  code: 'ESOCKET',
  path: undefined,
  host: '34.117.234.7',
  port: 465,
  localAddress: undefined,
  command: 'CONN'
}

i tried changing the port to 587 and the secure to false and the error became this

Error: Connection closed
Saybers
  • 39
  • 5

0 Answers0