简体   繁体   中英

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: 'info@mydomain.de',
        password: 'mypassword',
    }
});

var mailOptions = {
    from: 'info@mydomain.de',
    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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM