I am getting this error in production when the GCP VM instance tries to send mail, while it works locally.
{ "textPayload": "Error: Connection timeout\n at SMTPConnection._formatError (/usr/src/app/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)\n at SMTPConnection._onError (/usr/src/app/node_modules/nodemailer/lib/smtp-connection/index.js:770:20)\n at Timeout.<anonymous> (/usr/src/app/node_modules/nodemailer/lib/smtp-connection/index.js:229:22)\n at listOnTimeout }
const transporter = createTransport({
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: {
user: "user",
pass: "pass", // gmail pass
},
});
I have tried the App password too.
I think the problem was the firewall and after many attempts issue still was not fixed. So I created a cloud function to send emails.