How to solve CERT_UNTRUSTED error in nodemailer

14.1k views Asked by At

I am trying to send an email with nodemailer. I already managed to send it from another host but now I want to send emails from another address. These are the versions of nodemailer I am using (from my package.json):

"nodemailer": "1.3.4",
"nodemailer-smtp-transport": "1.0.2",

This is the information I have about my webmail:

RoundCube Mail Client Configuration

I set up nodemailer like this:

    var transport = nodemailer.createTransport(smtpTransport({
        host: 'securemail.linevast.de',
        port: 465,
        secure: true,
        auth: {
            user: '[email protected]', // this is my login name
            pass: 'mypassword'
        },
        maxConnections: 5,
        maxMessages: 10
    }));

And when I try to send an email I get the following error message.

[Error: certificate not trusted] code: 'CERT_UNTRUSTED'

The website is verified by GeoTrust Inc so I believe it is quite trustworthy. Is there a way to make nodemailer trust the certificate or force it to send the email even though it does not trust it?

Thank you for your help!

1

There are 1 answers

5
jmingov On BEST ANSWER

Yes, you can tell nodemailer to not check the certificate trust.

This is the option:

tls: {rejectUnauthorized: false}

use it on the initial transport object:

var transporter = nodemailer.createTransport(smtpTransport('SMTP',{
        host: 'mail.mailserver.com',
        port: 587,
        auth: {
            user: '[email protected]',
            pass: 'passwd'
        },            
        authMethod:'NTLM',
        secure:false,
        // here it goes
        tls: {rejectUnauthorized: false},
        debug:true
    })
);