smtp-connection
Advanced tools
Comparing version 2.2.6 to 2.3.0
# Changelog | ||
## v2.3.0 2016-02-17 | ||
* Do not modify provided options object | ||
## v2.2.6 2016-02-16 | ||
@@ -4,0 +8,0 @@ |
@@ -50,8 +50,15 @@ 'use strict'; | ||
this.options.port = this.options.port || (this.options.secure ? 465 : 25); | ||
this.options.host = this.options.host || 'localhost'; | ||
this.options.secure = !!this.options.secure; | ||
this.secureConnection = !!this.options.secure; | ||
this.alreadySecured = !!this.options.secured; | ||
this.options.name = this.options.name || this._getHostname(); | ||
this.port = this.options.port || (this.secureConnection ? 465 : 25); | ||
this.host = this.options.host || 'localhost'; | ||
if (typeof this.options.secure === 'undefined' && this.port === 465) { | ||
// if secure option is not set but port is 465, then default to secure | ||
this.secureConnection = true; | ||
} | ||
this.name = this.options.name || this._getHostname(); | ||
this.logger = shared.getLogger(this.options); | ||
@@ -82,3 +89,3 @@ | ||
*/ | ||
this.secure = false; | ||
this.secure = !!this.secureConnection; | ||
@@ -138,6 +145,2 @@ /** | ||
this._closing = false; | ||
if (this.options.secure) { | ||
this.secure = true; | ||
} | ||
} | ||
@@ -159,4 +162,4 @@ util.inherits(SMTPConnection, EventEmitter); | ||
var opts = { | ||
port: this.options.port, | ||
host: this.options.host | ||
port: this.port, | ||
host: this.host | ||
}; | ||
@@ -171,3 +174,3 @@ | ||
this._socket = this.options.connection; | ||
if (this.options.secure && !this.options.secured) { | ||
if (this.secureConnection && !this.alreadySecured) { | ||
setImmediate(this._upgradeConnection.bind(this, function (err) { | ||
@@ -187,7 +190,7 @@ if (err) { | ||
try { | ||
this._socket.connect(this.options.port, this.options.host, this._onConnect.bind(this)); | ||
this._socket.connect(this.port, this.host, this._onConnect.bind(this)); | ||
} catch (E) { | ||
return setImmediate(this._onError.bind(this, E, 'ECONNECTION')); | ||
} | ||
} else if (this.options.secure) { | ||
} else if (this.secureConnection) { | ||
// connect using tls | ||
@@ -200,3 +203,3 @@ if (this.options.tls) { | ||
try { | ||
this._socket = tls.connect(this.options.port, this.options.host, opts, this._onConnect.bind(this)); | ||
this._socket = tls.connect(this.port, this.host, opts, this._onConnect.bind(this)); | ||
} catch (E) { | ||
@@ -551,3 +554,3 @@ return setImmediate(this._onError.bind(this, E, 'ECONNECTION')); | ||
socket: this._socket, | ||
host: this.options.host | ||
host: this.host | ||
}; | ||
@@ -729,6 +732,6 @@ | ||
this._currentAction = this._actionLHLO; | ||
this._sendCommand('LHLO ' + this.options.name); | ||
this._sendCommand('LHLO ' + this.name); | ||
} else { | ||
this._currentAction = this._actionEHLO; | ||
this._sendCommand('EHLO ' + this.options.name); | ||
this._sendCommand('EHLO ' + this.name); | ||
} | ||
@@ -774,3 +777,3 @@ }; | ||
this._currentAction = this._actionHELO; | ||
this._sendCommand('HELO ' + this.options.name); | ||
this._sendCommand('HELO ' + this.name); | ||
return; | ||
@@ -780,3 +783,3 @@ } | ||
// Detect if the server supports STARTTLS | ||
if (!this.secure && !this.options.ignoreTLS && (/[ \-]STARTTLS\r?$/mi.test(str) || this.options.requireTLS)) { | ||
if (!this.secureConnection && !this.options.ignoreTLS && (/[ \-]STARTTLS\r?$/mi.test(str) || this.options.requireTLS)) { | ||
this._sendCommand('STARTTLS'); | ||
@@ -849,3 +852,3 @@ this._currentAction = this._actionSTARTTLS; | ||
this._currentAction = this._actionEHLO; | ||
this._sendCommand('EHLO ' + this.options.name); | ||
this._sendCommand('EHLO ' + this.name); | ||
} else { | ||
@@ -852,0 +855,0 @@ this.emit('connect'); |
{ | ||
"name": "smtp-connection", | ||
"version": "2.2.6", | ||
"version": "2.3.0", | ||
"description": "Connect to SMTP servers", | ||
@@ -5,0 +5,0 @@ "main": "lib/smtp-connection.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51142
1113