25

I am creating the transport object like this.

var transport = nodemailer.createTransport("SMTP", {
        host: "smtp-mail.outlook.com", // hostname
        secureConnection: false, // use SSL
        port: 587, // port for secure SMTP
        auth: {
            user: "user@outlook.com",
            pass: "password"
        }
    });

This is the error which I am getting, when I try to send the mail.

[Error: 139668100495168:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:../deps/openssl/openssl/ssl/s3_pkt.c:337: ]

When I tried setting ignoreTLS as true. This is what I am getting

{ [AuthError: Invalid login - 530 5.7.0 Must issue a STARTTLS command first] name: 'AuthError', data: '530 5.7.0 Must issue a STARTTLS command first' }

Am I doing something wrong? Please help.

Jeevan
  • 3,878
  • 6
  • 29
  • 37

8 Answers8

48

I was having the same issue until I stumbled upon https://github.com/andris9/Nodemailer/issues/165

Try adding the tls cipher option to use SSLv3.

var transport = nodemailer.createTransport("SMTP", {
    host: "smtp-mail.outlook.com", // hostname
    secureConnection: false, // TLS requires secureConnection to be false
    port: 587, // port for secure SMTP
    auth: {
        user: "user@outlook.com",
        pass: "password"
    },
    tls: {
        ciphers:'SSLv3'
    }
});

Alternatively, for hotmail/live/outlook you can simply use

var transport = nodemailer.createTransport("SMTP", {
    service: "hotmail",
    auth: {
        user: "user@outlook.com",
        pass: "password"
    }
});
Ray L
  • 596
  • 5
  • 2
3
let testAccount = await nodemailer.createTestAccount();
let transporter = nodemailer.createTransport({
  service: "Outlook365",
  host: "smtp.office365.com",
  port: "587",
  tls: {
    ciphers: "SSLv3",
    rejectUnauthorized: false,
  },
  auth: {
    user: "**********",
    pass: "*******",
  },
});
let info = await transporter.sendMail({
  from: "********", // sender address
  to: to, // list of receivers
  subject: subject, // Subject line
  html: html, // html body
});

You can use thing configuration for nodemailer with outlook account
0

If you are using Nodemailer 1.x or greater you can use:

var transporter = nodemailer.createTransport('smtp://username%40outlook.com:password@smtp-mail.outlook.com');
Richie_b
  • 149
  • 1
  • 6
0

basically, error from SSLv3, so i have the solution from my

let transporter = nodemailer.createTransport({
    host: 'smtp-mail.outlook.com',                  // hostname
    service: 'outlook',                             // service name
    secureConnection: false,
    tls: {
        ciphers: 'SSLv3'                            // tls version
    },
    port: 587,                                      // port
    auth: {
        user: "<Your Email>",
        pass: "<Password>"
    }
});
rajkanani
  • 173
  • 3
  • 5
0

if you are using v5+

const transporter = nodemailer.createTransport({
  host: "smtp-mail.outlook.com", 
  secureConnection: false, 
  port: 587, 
  service: "outlook",
  auth: {
    user: process.env.EMAIL_ID,
    pass: process.env.EMAIL_PASSWORD,
  },
  tls: {
    ciphers: "SSLv3",
  },
});
0

its worked for me in Nodemailer version 6.9.1 and have not any issue with typescript

const transporter = nodemailer.createTransport({
  host: "smtp-mail.outlook.com",
  port: 587,
  tls: {
    ciphers: "SSLv3",
    rejectUnauthorized: false,
  },
  auth: {
    user: "the  your username",
    pass: "the your pass",
  },
});
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
0

It worked for me in Nodemailer version 6.9.1 and have not any issue with typescript.

Just remove secureConnection: false and add rejectUnauthorized: false to tls object.

const transporter = nodemailer.createTransport({
  host: "smtp-mail.outlook.com",
  port: 587,
  tls: {
    ciphers: "SSLv3",
    rejectUnauthorized: false,
  },
  auth: {
    user: "the  your username",
    pass: "the your pass",
  },
});
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
-3

tls: { ciphers:'SSLv3' } +1 working

and for first agr ("SMTP", is not support later version . one will have to downgrade nodemailler