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

Prasad Silva picture Prasad Silva · Apr 23, 2015 · Viewed 11.2k times · Source

I'm trying to use Office365 SMTP to send email using Nodemailer (in a MEANjs scaffold), 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'm using the following Nodemailer options:

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

Removing the tls field doesn't make a difference. What am I missing?

Answer

Prasad Silva picture Prasad Silva · Apr 23, 2015

The solution was simple. The 'secure' field should be 'secureConnection'. The MEANjs scaffold that generated the configs created mailer options with the 'secure' field. The rest of the options are fine. For anyone that needs a working Office365 SMTP nodemailer options block, the following should work:

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