#Resend nodemailer - not sending emails

1 messages · Page 1 of 1 (latest)

magic rampart
#

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 protected], 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: "[email protected]",
            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

copper dawnBOT
severe parrot
#

I would verify you can hit the smtp server/port from your env using telnet or netcat (nc)

magic rampart
#

I'll try this today. Thanks Elliot

magic rampart
#

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

severe parrot
#

Yeah, definitely seems like something in your environment - not payload related.

magic rampart
#

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!

copper dawnBOT
#

This thread is already marked as solved.

outer loom
#

@severe parrot 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)