ztefanie
ztefanie

Reputation: 850

Nodemailer problems with tls/certificate (SMTP)

I want to send an e-mail with nodemailer, my configurations are:

var nodemailer = require('nodemailer');

var transporter = nodemailer.createTransport({
    host: 'smtp.mydomain.de',
    port: 25,
    logger: true,
    auth: {
        user: '[email protected]',
        password: 'mypassword',
    }
});

var mailOptions = {
    from: '[email protected]',
    to: recipient,
    subject: 'subject',
    text: '<p>hallo</p>'
};


transporter.sendMail(mailOptions, function (error, info) {
    if (error) {
        console.log("Error in sendMail:");
        console.log(error);
    } else {
        console.log('Email sent: ' + info.response);
    }
});

I got an error: "Error: Hostname/IP doesn't match certificate's altnames:...", after some research i added:

    tls: {
        rejectUnauthorized: false
    }

to my transporter. And now i get:

Error: Missing credentials for "PLAIN"

I have no idea, what to change. I have the certificate for sending with SSL, but don't know where to put it nor which credentials are missing.

Upvotes: 0

Views: 5446

Answers (1)

Ashish
Ashish

Reputation: 643

You can try following tls options if you're ok with disabling TLS

tls: {
    secure: false,
    ignoreTLS: true,
    rejectUnauthorized: false
}

Upvotes: 2

Related Questions