Talha Zahid
Talha Zahid

Reputation: 1

Nodemailer timed Out Error: connect ETIMEDOUT 64.233.184.109:587 errno: -4039,

Error in sending Email through Node mailer. Everything in the code is right but it is giving error of timedOut I am aready using App Password generated by google account Below is my function

The Host and port are

SMTP_HOST=smtp.gmail.com SMTP_PORT=587


``

    const transporter = nodemailer.createTransport({
    host: process.env.SMTP_HOST,
    port: process.env.SMTP_PORT,
    secure: false, // Use `true` for port 465, `false` for all other ports
    auth: {
    user: process.env.SMTP_MAIL,
    pass: process.env.SMTP_PASSWORD,
  },
});


app.post("/sendEmail", async (req, res) => {
  const { email, subject, message } = req.body;
  console.log(email, subject, message);

  var mailOptions = {
    from: process.env.SMTP_MAIL,
    to: email,
    subject: subject,
    text: message,
  };

  transporter.sendMail(mailOptions, function (error, info) {
    if (error) {
      console.log(error);
    } else {
      console.log("Email sent successfully!");
    }
  });
});

`
`

The response it is giving is

Error: connect ETIMEDOUT 64.233.184.109:587 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) { errno: -4039, code: 'ESOCKET', syscall: 'connect', address: '64.233.184.109', port: 587, command: 'CONN' }

I have tried changing port and host but each time it is giving the same error.

I don't think there is any mistake in the code but some port or host or something like that is causing problem

Upvotes: 0

Views: 54

Answers (0)

Related Questions