Answer the question
In order to leave comments, you need to log in
Why does nodemailer only send emails from localhost?
On the node.js express server, I have a router that is responsible for sending emails when a user registers on the site.
Router:
var express = require('express');
var router = express.Router();
var fs = require('fs');
const nodemailer = require('nodemailer');
router.post('/send/confirmMail', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.contentType('json');
res.setHeader('Content-Type', 'application/json');
var transporter = nodemailer.createTransport({
host: "smtp.mail.ru",
secureConnection: true,
port: 465,
auth: {
user: /*имя пользователя*/,
pass: /*пароль*/
},
tls: {
// do not fail on invalid certs
rejectUnauthorized: false
}
});
transporter.sendMail({
from: '[email protected]',
to: req.body.email,
subject: 'Подтверждение e-mail адреса.',
html: /*html-письмо*/
}, (error, info) => {
if (error) {
res.status(500).send(JSON.stringify({err: error, inf: info}));
return console.log(error);
} else {
res.status(200).end();
}
});
});
module.exports = router;
address: "217.69.139.160"
code: "ESOCKET"
command: "CONN"
errno: "ETIMEDOUT"
port: 465
syscall: "connect"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question