When I try to send an e-mail using nodemailer I got an connection timeout error with code 'ETIMEDOUT', but when I try on my notebook there's no error, both using the same e-mail account and password.
This is the file 'mail.js':
const nodemailer = require('nodemailer');
const user = process.env.EMAIL;
const pass = process.env.EMAIL_PASS;
const transporter = nodemailer.createTransport({
service: 'kinghost',
host: 'smtp.kinghost.net',
port: 587,
secure: false,
pool: true,
auth: { user, pass }
});
module.exports = {
sendMail(to, subject, html) {
const mailOptions = {
from: user,
to,
subject,
html
};
console.log(user)
transporter.sendMail(mailOptions, (err, info) => {
if (err) {
console.log(err)
};
console.log(`Mail to ${mail} has been sended`);
});
}
};