Error sending email using nodemailer via smtp Office365 (MEANjs scaffold)

I'm trying to use Office365 SMTP to send email using Nodemailer (in scaffold MEANjs), but I get the following error:

[Error: 140735277183760:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:795:] 

I use the following Nodemailer options:

 { host: 'smtp.office365.com', port: '587', auth: { user: 'xxxx', pass: 'xxxx' }, secure: 'false', tls: { ciphers: 'SSLv3' } } 

Removing the tls field does not matter. What am I missing?

+9
email meanjs office365 nodemailer
source share
3 answers

The solution was simple. The "secure" field must be "secureConnection". The MEANjs environment, which generated the configurations, created the mail program parameters with a "protected" field. The remaining options are in order. For those who need the Office365 SMTP nodemailer work package, the following should work:

 { host: 'smtp.office365.com', port: '587', auth: { user: 'xxxx', pass: 'xxxx' }, secureConnection: false, tls: { ciphers: 'SSLv3' } } 
+20
source share

The documentation for this node https://nodemailer.com/2-0-0-beta/setup-smtp/ does indicate options.secure, not options.secureConnection. The example also assumes that options.secure expects a boolean value of true or false, rather than a string value of 'true' or 'false' . Removing '' from 'false' works for me.

+4
source share

I know this is old, but if someone is looking for this in 2019, you can simply add service: "Outlook365"

and you won’t need to specify connection parameters.

Node Mailer Docs

 let transporter = nodemailer.createTransport({ service: "Outlook365", auth: { user: 'FROMUSER@office365.com', pass: 'FROMUSERPASS' }, }) let info = transporter.sendMail({ from: 'FROMUSER@office365.com', to: 'TOUSER@office365.com', subject: 'Test', text: 'hello world', html: '<h1>TEST</h1>' }) 
0
source share

All Articles