OVHcloud Community

Welcome to your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.

Nodemailer in Javascript with SMTP connection to Email Pro Email - Not Working


#1

Hello there,

I am currently attempting to use Nodemailer in my Express.js server to send emails but it doesn’t seem to work for me. I have used the verify function from Nodemailer to check if the connection via SMTP was successful and this is returned from the request:

{
    "code": "EAUTH",
    "response": "535 5.7.1 Authentication failed",
    "responseCode": 535,
    "command": "AUTH PLAIN"
}

Here is the code in Javascript I am using to send an email with Nodemailer with my custom domain:

app.get('/mail/verify', (req, res) => {
    var transporter = nodemailer.createTransport({
        host: process.env.MAIL_HOST,
        port: process.env.MAIL_PORT,
        secure: process.env.MAIL_SECURE,
        auth: {
            user: process.env.MAIL_USER,
            pass: process.env.MAIL_PASS
        },
        tls: {
            rejectUnauthorized: false
        },
    });

    transporter.verify((err, success) => {
        if (err) {
            res.send(err);
        } else {
            res.send('Server is ready to take our messages!');
        }
    });
});

These are the .env variables I am using:

MAIL_HOST = 'ssl0.ovh.net'
MAIL_PORT = 465
MAIL_SECURE = true
MAIL_USER = 'example@email.com'
MAIL_PASS = 'password'

If I replace ‘ssl0.ovh.net’ with the server of my Email Pro, I get a ETIMEOUT error. Does anyone know what may be causing this and what I can do to make this work?

Thank you for taking the time to read this and I look forward to any responses!