I have a Node.js + Express app using Nodemailer.
Email sending works locally with Gmail SMTP, but in production on Render it always times out.
Setup:
Host: smtp.gmail.com
Primary port: 465 (secure: true)
Fallback port: 587 (secure: false, STARTTLS)
Same credentials and app password as local
Increased timeouts to 30 seconds
Production logs:
Primary SMTP send failed, retrying on fallback SMTP port: SMTP primary send timeout after 30000ms
Failed to send verification email: Error: SMTP fallback send timeout after 30000ms
My transport setup (simplified):
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST, // smtp.gmail.com
port: Number(process.env.SMTP_PORT), // 465
secure: true,
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS,
},
connectionTimeout: 30000,
greetingTimeout: 30000,
socketTimeout: 30000,
});
Send function:
await transporter.sendMail({
from: process.env.MAIL_FROM,
to,
subject,
text,
html,
});
Notes:
App is not serverless; it’s a long-running Render web service.
HTTP endpoints work fine in production.
This seems like only outbound SMTP is failing.
If I use an HTTP email API (Resend), sending works in production.
Question:
Is there anything else to try with Nodemailer/Gmail SMTP in this environment, or is this likely outbound SMTP/network restriction from Render to Gmail (465/587)?
If it’s environment-related, what’s the recommended production approach?