Nodemailer DNS resolution

Hello,
I am using new Forge runtime and I am trying to send an email using ‘nodemailer’ module but it seems that DNS resolution doesn’t work.
The code is like:

  let transporter = nodemailer.createTransport({
    host: EMAIL_HOST
    port: 587,
    secure: false,
    auth: {
      user: EMAIL_USER,
      pass: EMAIL_PASS
    },
    tls: {
      rejectUnauthorized: false,
    },
    debug: true,
    logger: true,
  });
  let mailOptions = {
    from: EMAIL_USER,
    to: EMAIL_RECIPIENT
    subject: "Hello",
    html: "<b>whatever</b>",
  };
  const response = await transporter.sendMail(mailOptions);

and the error is: Error: getaddrinfo ENOTFOUND EMAIL_HOST.
Even using ‘dns’ module and trying to lookup for an address yields same results:

  dns.setServers([
    "8.8.8.8",
    "8.8.4.4"])
  await dns.lookup(EMAIL_HOST); // error

What could possibly go wrong? Same code without dns part does work on my local machine. The host is not restricted by any VPN connections or any of that.

@Nowak,

The Forge Runtime only allows outgoing network connections for HTTPS. Your app won’t be able to send emails directly.

1 Like