Getting timeout errors when sending emails through Gmail SMTP
I’m experiencing connection timeouts when trying to send emails using Nodemailer with Gmail SMTP. This is really frustrating because the same setup worked fine in my previous project, but now even that old project is failing with identical timeout errors.
I’ve tested with multiple Gmail accounts - some with 2FA enabled, one configured with XOAuth, and another with less secure apps enabled. All of them result in the same timeout problem.
Here’s my current configuration:
const mailConfig = {
service: "Gmail",
connectionTimeout: "7000",
greetingTimeout: "7000",
auth: {
user: myEmailAddress,
pass: myAppPassword
},
secure: true,
debug: true
};
And here’s how I create the transport:
const transporter = nodemailer.createTransport(smtpTransport(mailConfig), () => {
console.log('Transport created');
});
The callback function never executes, even with console.log statements inside.
I tested the connection manually using:
openssl s_client -crlf -connect smtp.gmail.com:465
This command times out on my machine, but works perfectly when my friend tries it on his computer. This suggests the issue is specific to my system rather than Gmail’s servers.
I’ve already disabled my firewall and tried different ports without success. Any ideas what could be causing this local connection issue?