K.Broncel
K.Broncel

Reputation: 79

Cannot send mail with nodemailer and postfix

I have a VPS in OVH, its ubuntu. I've installed postfix there and I can send email directly from terminal (using mail <addres@host>).

I'm trying to send email using node.js application and I'm constantly getting Error: Invalid login: 535 5.7.8 Error: authentication failed: authentication failure

Node code:

let transporter = nodemailer.createTransport({
    host: 'localhost',
    port: 25,
    auth: {
        user: 'systemUser', - should it be actual linux user?
        pass: 'systemUserPassword'
    },
    tls:{
        rejectUnauthorized: false
    }
});
transporter.verify(function (error, success) {
    if (error) {
        console.log(error)
    }
    else {
        console.log("success")
    }
})

Upvotes: 0

Views: 1976

Answers (2)

suckschool
suckschool

Reputation: 307

You can probably find the answer here: https://stackoverflow.com/a/54103349/9767510

I'd post it here, but the silly rules don't like it. And it took me a while to figure this out, and this never got answered properly ever. And I found all these posts with no solution ever presented (but mods are glad to delete the answer either way - which helps no one and is counter-productive). People just want the answers.

The other comment didn't even contribute anything and was left up. Irony.

Upvotes: 1

user1366860
user1366860

Reputation:

It's been a while since I've done anything with a regular SMTP/Sendmail. Have you tried to use Sendmail transport instead of the regular SMTP one?

https://nodemailer.com/transports/sendmail/

Upvotes: 0

Related Questions