I have an api which sends email when a user submits data on the frontend. I can't get the nodemailer sendmail to work.
nodemailer.js -
const nodemailer = require("nodemailer");
async function sendmail(data) {
let transporter = nodemailer.createTransport({
host: "www.google.com",
port: 587,
secure: false,
auth: {
user: <my email>,
pass: <password>,
},
});
await transporter.sendMail(
{
from: data.email,
to: <my email>,
subject: "CEWA Feedback",
text: data.message,
html: "<b>Hello world?</b>",
},
(err) => {
console.log(err);
}
);
}
module.exports = sendmail;
When this function runs I get this error in the console -
Error: connect ETIMEDOUT 216.58.221.36:587
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'ETIMEDOUT',
code: 'ESOCKET',
syscall: 'connect',
address: '216.58.221.36',
port: 587,
command: 'CONN'
}
Any idea what's going wrong? Thanks in advance.
question from:
https://stackoverflow.com/questions/65871796/nodemailer-error-connect-etimedout-216-58-221-36587 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…