diff --git a/lib/smtp.js b/lib/smtp.js index 8a657249..d8d68dd2 100644 --- a/lib/smtp.js +++ b/lib/smtp.js @@ -507,11 +507,10 @@ SMTPClient.prototype._handshakeListener = function(data, callback){ } /** - * smtp.SMTPClient#_handshakeListener(data) -> undefined - * - data(String): String received from the server + * smtp.SMTPClient#_starttlsHandler(callback) -> undefined + * - callback (Function): Function to be run after connection * - * Server data listener for the handshake - waits for the 220 response - * from the server (connection established). + * Initiates a TLS session with the server **/ SMTPClient.prototype._starttlsHandler = function(callback){ if(this.debug){ @@ -526,18 +525,18 @@ SMTPClient.prototype._starttlsHandler = function(callback){ this.ignore_data = true; var ssl_socket; ssl_socket = starttls(this._connection, this.options, (function(){ + + if(this.debug && !ssl_socket.authorized){ + console.log("▒▒▒ WARNING: TLS ERROR ("+ssl_socket.authorizationError+") ▒▒▒"); + } + ssl_socket.on("data",this._onData); this._connection.removeListener("data",this._onData); this._connection = ssl_socket; this.ignore_data = false; this._data_remainder = ""; this.emit("connection_stable"); - if(!this._connection.authorized && this.options.use_authentication) { - callback(); - } - else{ - this._loginHandler(callback); - } + callback(); }).bind(this)); }).bind(this)); } diff --git a/lib/starttls.js b/lib/starttls.js index 3f901de9..fbff2a2a 100644 --- a/lib/starttls.js +++ b/lib/starttls.js @@ -21,7 +21,7 @@ module.exports = function starttls(socket, options, cb) { cleartext = pipe(pair, socket); pair.on('secure', function() { - var verifyError = !pair._ssl || pair._ssl.verifyError(); + var verifyError = (pair._ssl || pair.ssl).verifyError(); if (verifyError) { cleartext.authorized = false; diff --git a/package.json b/package.json index bd7c0710..77ac4c62 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodemailer", "description": "Easy to use module to send e-mails, supports unicode and SSL/TLS", - "version": "0.1.18", + "version": "0.1.19", "author" : "Andris Reinman", "maintainers":[ {