Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to connect to outlook.com SMTP using Nodemailer

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: "[email protected]",
            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.

like image 454
Jeevan Avatar asked Oct 22 '13 05:10

Jeevan


People also ask

How do I use Nodemailer in Outlook?

Getting Started. var nodeoutlook = require('nodejs-nodemailer-outlook') nodeoutlook. sendEmail({ auth: { user: "[email protected]", pass: "********" }, from: '[email protected]', to: '[email protected]', subject: 'Hey you, awesome! ', html: '<b>This is bold text</b>', text: 'This is text version!


2 Answers

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: "[email protected]",
        pass: "password"
    },
    tls: {
        ciphers:'SSLv3'
    }
});

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

var transport = nodemailer.createTransport("SMTP", {
    service: "hotmail",
    auth: {
        user: "[email protected]",
        pass: "password"
    }
});
like image 99
Ray L Avatar answered Sep 28 '22 23:09

Ray L


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
like image 1
vishal sharma Avatar answered Sep 30 '22 23:09

vishal sharma