Nodemailer SMTP Authentication Issue (Error 535 5.7.8) with Railway Deployment

sebastianhr1TRIAL

6 months ago

Hi everyone,

I'm currently working on a Node.js project for generating QR codes and emailing them to users using Nodemailer. However, I keep encountering an authentication issue that I can't resolve.

Context:

  • I am deploying my backend with Railway.

  • I am using Nodemailer for sending emails.

  • The SMTP credentials (user and password) are from Namecheap (mail.privateemail.com) and have been verified.

  • I have used SMTP Test Tool, and I was able to successfully send emails using the credentials, so they seem to be correct.

Nodemailer Configuration Code:

const transporter = nodemailer.createTransport({

host: "mail.privateemail.com", // Namecheap SMTP server

port: 587,

secure: false, // true for port 465, false for other ports

requireTLS: true,

auth: {

user: process.env.SMTP_USER, // SMTP email

pass: process.env.SMTP_PASS // SMTP password

},

tls: {

rejectUnauthorized: false

}

});

Here is the error I get when trying to send the email: Error sending email: Error: Invalid login: 535 5.7.8 Error: authentication failed: (reason unavailable)

What I've Tried So Far:

  • I verified the environment variables in Railway, and they are correctly set.

  • Tried using secure: false and requireTLS: true.

  • The credentials work when tested externally using SMTP Test Tool.

  • I added tls: { rejectUnauthorized: false } to avoid potential certificate issues.

My Question:

Has anyone faced a similar issue with Nodemailer and Railway? Could it be related to Railway's configuration when handling SMTP connections?

I would greatly appreciate any guidance on how to solve this issue. The credentials appear to be correct, and the external tool worked fine, so I'm stuck at this point.

Thanks in advance for your help!

0 Replies

Nodemailer SMTP Authentication Issue (Error 535 5.7.8) with Railway Deployment - Railway Help Station