Answer the question
In order to leave comments, you need to log in
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?
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
The problem was in the hosting itself and the fact that it blocked the connection to third-party smtp servers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question