S
S
straystreyk2021-11-14 22:08:43
JavaScript
straystreyk, 2021-11-14 22:08:43

Nodemailer works on local server, but does not work on hosting. What can be wrong?

I deployed the project on the hosting, locally - everything works, but on the hosting in the logs of the server part it gives an error when sending . What could be the reason?
61915e8f4e971935855288.jpeg

router.post("/api/sendmail", async (req, res) => {
  const mailTransport = nodemailer.createTransport({
    host: "smtp.mail.ru",
    port: 465,
    secure: true,
    auth: {
      user: process.env.mailLogin,
      pass: process.env.mailPass,
    }
  });
  try {
    await mailTransport.sendMail({
      from: process.env.mailLogin,
      to: "[email protected]",
      subject: "ТЕКСТ",
      html: `ТЕКСТ`,
    });
    res
      .status(200)
      .send(JSON.stringify({ mess: "Ваш заказ принят в обработку" }));
  } catch (e) {
    res.status(400);
    console.log(e.message);
  }
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
straystreyk, 2021-11-16
@straystreyk

The problem was in the hosting itself and the fact that it blocked the connection to third-party smtp servers.

T
ThunderCat, 2021-11-14
@ThunderCat

It looks like you have

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question