Nodemailer not working in production

I need a simple functionality to email myself forms from my website with low traffic. I have done this using Nodemailer last year and everything was working correctly looking like this:

const transporter = nodemailer.createTransport({
      host: "mailproxy.nameserver.sk",
      port: 25,
      secure: false,
      auth: {
        user: process.env.EMAIL_USERNAME,
        pass: process.env.EMAIL_PASSWORD,
      },
    });

const message = {
      from: process.env.EMAIL_FROM,
      to: process.env.EMAIL_TO,
      subject: ...,
      html: `...`
    };

const info = await transporter.sendMail(message);

However, now in production none of the ports work: 465 with secure true, nor 587, nor 25 with secure false. Every one of those ports works properly in my local environment but none of them work in production.

My env variables are for sure correct. I have also contacted my domain and email services provider and we have concluded that the IP of my webserver is not blocked on their side. I have used the following when setting up the transformer:

logger: true, 
debug: true

And found out that in my local environment:

[2024-03-05 22:06:07] DEBUG Sending mail using SMTP/6.9.10[client:6.9.10]
[2024-03-05 22:06:07] DEBUG [YPTW28uku74] Resolved mailproxy.nameserver.sk as ....81 [cache miss]
[2024-03-05 22:06:07] INFO  [YPTW28uku74] Connection established to ....81:25
Followed by some info regarding successful delivery of the email.

In the production environment it stopped after the [cache miss] line and after app. 2 minutes it threw CONNECTION TIMEOUT error.

So the question is, has something changed on Fly’s side that I need to adjust my code either in the transporter or maybe in fly.toml? My current fly.toml looks like this:

app = "..."
primary_region = "waw"
kill_signal = "SIGINT"
kill_timeout = "5s"

[experimental]
  auto_rollback = true

[env]
  PORT = "8080"
  PRIMARY_REGION = "waw"

[[services]]
  protocol = "tcp"
  internal_port = 8080
  processes = ["app"]

  [[services.ports]]
    port = 80
    handlers = ["http"]
    force_https = true

  [[services.ports]]
    port = 443
    handlers = ["tls", "http"]
  [services.concurrency]
    type = "connections"
    hard_limit = 25
    soft_limit = 20

  [[services.tcp_checks]]
    interval = "15s"
    timeout = "2s"
    grace_period = "1s"
    restart_limit = 0

Thank you in advance.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.