3

I am trying to send a email using Nodemailer with these configurations :

var transporter = nodemailer.createTransport(smtpTransport({
          host: 'smtp.outlookhost',
          port: 25,
          auth: {
            user: '',
            pass: ''
          },
          secure:false,
          logger: true,
          debug: true
        }));

I am getting this error :

Error: unable to get local issuer certificate

I am using outlook to send email. How can I provide certificates.

Modified the configurations :

 var transporter = nodemailer.createTransport(smtpTransport({
              host: 'smtp.outlookhost',
              port: 25,
              auth: {
                user: '',
                pass: ''
              },
              secure:true,
              logger: true,
              debug: true,
              tls: {
              // do not fail on invalid certs
              rejectUnauthorized: false
            }
    }));

Error :

Error: 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c
Naveen
  • 773
  • 3
  • 17
  • 40

3 Answers3

6
  const transporter = nodemailer.createTransport({
    host: "smtp.outlookhost",
    port:  25,
    secure: false,
    tls: {rejectUnauthorized: false}
  });

Late answer, but this worked for me using the current version of nodemailer and an outlook host.

Lucas Crämer
  • 136
  • 1
  • 5
1

Maybe this might help you:
Not able to connect to outlook.com SMTP using Nodemailer

I would use the second approach, as it is easier! =D

var transport = nodemailer.createTransport("SMTP", {
    service: "hotmail",
    auth: {
        user: "user@outlook.com",
        pass: "password"
    }
});
0

In my case nodemailer couldn't find our corporate CA certificate. So I set ca option and it solved the issue. CA cert is in PEM format and begins with -----BEGIN CERTIFICATE----- and ends with -----END CERTIFICATE-----.

const fs = require('fs');
const path = require('path');
const transporter = nodemailer.createTransport({
  host: 'smtp-server',
  port: 25,
  tls: {
    ca: [ fs.readFileSync(path.resolve(__dirname, 'ca.pem')) ],
  },
});
Anton
  • 51
  • 1
  • 4