Nodemailer: Unknown protocol error with secure SMTP transport

Created on 4 Apr 2016  路  5Comments  路  Source: nodemailer/nodemailer

I can't get smtps to work at all, no matter what machine or version of Node I try (four different machines). Nodemailer 2.3.0, Node 0.12.1, 4.2.1, 4.2.3, and 4.4.2, on Windows 10 and OS X 10.10.5 and others.

$ node -e "require('nodemailer').createTransport('smtps://smtp.gmail.com:587').sendMail({}, function(e) {console.log(e);})"
[Error: 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:794:]

I get the same result for smtps://smtp.postmarkapp.com:587. CheckTLS and a raw openssl command both connect fine, so I'm pretty sure the problem is not with the SMTP servers. openssl indicates that all protocols from SSLv3 up to TLS1.2 are supported so it shouldn't be a secureProtocol issue as hinted at in #358.

The error points to this line in openssl, which AFAICT means that the ServerHello packet just can't be parsed at all.

Any idea what I'm doing wrong? Or is smtps just broken in Nodemailer 2.3.0? Thanks.

Most helpful comment

Yes, the "s" in the end of any protocol name usually means that the connection should be initialized using TLS. This should work: smtp://smtp.gmail.com:587/?requireTLS=true

All 5 comments

I also tried nodemailer@beta with the same result.

Port 587 is not smtps but smtp. The connection starts out as plaintext and is later upgraded to TLS automatically (if supported by the server) by STARTTLS call. Use smtp://smtp.gmail.com:587 or smtps://smtp.gmail.com:465.

Ah, so smtps is equivalent to options.secure rather than options.requireTLS, is that it? OK.

Yes, the "s" in the end of any protocol name usually means that the connection should be initialized using TLS. This should work: smtp://smtp.gmail.com:587/?requireTLS=true

Oh awesome, I was just looking for that! Thanks! :sparkling_heart:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abhishekdgeek picture abhishekdgeek  路  5Comments

pranavpunjabi picture pranavpunjabi  路  3Comments

ghost picture ghost  路  3Comments

curlynux picture curlynux  路  5Comments

ryanrolds picture ryanrolds  路  4Comments