It was working before, but I'm getting this error in development and production recently
There is an error with the email configuration you have provided. Error: Connection timeout
Failed to send mail to email@gmail.com, subject: Reset Your Password
err: {
"type": "Error",
"message": "Connection timeout",
"stack":
Error: Connection timeout
at SMTPConnection._formatError (/home/webarto/node_modules/nodemailer/lib/smtp-connection/index.js:790:19)
at SMTPConnection._onError (/home/webarto/node_modules/nodemailer/lib/smtp-connection/index.js:776:20)
at Timeout.<anonymous> (/home/webarto/node_modules/nodemailer/lib/smtp-connection/index.js:235:22)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)
"code": "ETIMEDOUT",
"command": "CONN"
}
// server.ts
import nodemailer from "nodemailer";
// resend
const transport = nodemailer.createTransport({
host: "smtp.resend.com",
secure: true,
port: 465,
auth: {
user: "resend",
pass: "re_password",
},
});
...
await payload.init({
secret: process.env.PAYLOAD_SECRET,
express: app,
email: {
fromName: "Eustachio",
fromAddress: "support@website.com",
transport,
},
onInit: () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
},
...
I have checked firewalls for port 465 and it is open, I don't if there is another port or ip that is trying to communicate with the server and it isn't open
Any help would be great, please. Thank you
I would verify you can hit the smtp server/port from your env using telnet or netcat (nc)
https://netcorecloud.com/tutorials/smtp-connection-from-command-line/
I'll try this today. Thanks Elliot
I couldn't hit the smtp resend server using telnet, connection timeout. I think it's perhaps something to do with the smtp port and my server's firewalls
Don't know how to fix it. I'll try with another provider, gmail perhaps to see if it works
Yeah, definitely seems like something in your environment - not payload related.
I got it working. It turns out that the server has ports 465 and 25 blocked by default to avoid malicious requests. I'm using
port: 587
and
secure: false
and it is working well now. Thanks for helping!
@denolfe is it possible to have Payload not require nodemailer to function? I just tried generating graphQL Schema and it was complaining that it cannot connect to nodemailer.io (I was offline)
@tyteen4a03 The ethereal nodemailer is defaulted if no other email transport is provided. You could look up how to do a "dummy" nodemailer transport that writes to stout and modify accordingly. I believe nodemailer has this example in their docs. (On mobile atm, otherwise I'd link you)
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.