smtp-connection
Advanced tools
Comparing version 2.3.1 to 2.3.2
# Changelog | ||
## v2.3.2 2016-04-11 | ||
* Declare SMTPUTF8 usage if an address includes Unicode characters and the server indicates support for it. Fixes an issue with internationalized email addresses that were rejected by Gmail | ||
## v2.3.1 2016-02-20 | ||
@@ -4,0 +8,0 @@ |
@@ -115,2 +115,8 @@ 'use strict'; | ||
/** | ||
* Lists supported extensions | ||
* @private | ||
*/ | ||
this._supportedExtensions = []; | ||
/** | ||
* Function to run if a data chunk comes from the server | ||
@@ -517,3 +523,3 @@ * @private | ||
SMTPConnection.prototype._onTimeout = function () { | ||
return this._onError(new Error('Timeout'), 'ETIMEOUT'); | ||
return this._onError(new Error('Timeout'), 'ETIMEDOUT'); | ||
}; | ||
@@ -645,2 +651,5 @@ | ||
SMTPConnection.prototype._setEnvelope = function (envelope, callback) { | ||
var args = []; | ||
var useSmtpUtf8 = false; | ||
this._envelope = envelope || {}; | ||
@@ -661,2 +670,8 @@ this._envelope.from = (this._envelope.from && this._envelope.from.address || this._envelope.from || '').toString().trim(); | ||
// check if the sender address uses only ASCII characters, | ||
// otherwise require usage of SMTPUTF8 extension | ||
if (/[\x80-\uFFFF]/.test(this._envelope.from)) { | ||
useSmtpUtf8 = true; | ||
} | ||
for (var i = 0, len = this._envelope.to.length; i < len; i++) { | ||
@@ -666,2 +681,8 @@ if (!this._envelope.to[i] || /[\r\n<>]/.test(this._envelope.to[i])) { | ||
} | ||
// check if the recipients addresses use only ASCII characters, | ||
// otherwise require usage of SMTPUTF8 extension | ||
if (/[\x80-\uFFFF]/.test(this._envelope.to[i])) { | ||
useSmtpUtf8 = true; | ||
} | ||
} | ||
@@ -677,3 +698,10 @@ | ||
}.bind(this); | ||
this._sendCommand('MAIL FROM:<' + (this._envelope.from) + '>'); | ||
// If the server supports SMTPUTF8 and the envelope includes an internationalized | ||
// email address then append SMTPUTF8 keyword to the MAIL FROM command | ||
if (useSmtpUtf8 && this._supportedExtensions.indexOf('SMTPUTF8') >= 0) { | ||
args.push('SMTPUTF8'); | ||
} | ||
this._sendCommand('MAIL FROM:<' + (this._envelope.from) + '>' + (args.length ? ' ' + args.join(' ') : '')); | ||
}; | ||
@@ -779,3 +807,3 @@ | ||
// Detect if the server supports STARTTLS | ||
if (!this.secure && !this.options.ignoreTLS && (/[ \-]STARTTLS\r?$/mi.test(str) || this.options.requireTLS)) { | ||
if (!this.secure && !this.options.ignoreTLS && (/[ \-]STARTTLS\b/mi.test(str) || this.options.requireTLS)) { | ||
this._sendCommand('STARTTLS'); | ||
@@ -786,2 +814,7 @@ this._currentAction = this._actionSTARTTLS; | ||
// Detect if the server supports SMTPUTF8 | ||
if (/[ \-]SMTPUTF8\b/mi.test(str)) { | ||
this._supportedExtensions.push('SMTPUTF8'); | ||
} | ||
// Detect if the server supports PLAIN auth | ||
@@ -788,0 +821,0 @@ if (str.match(/AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)PLAIN/i)) { |
{ | ||
"name": "smtp-connection", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "Connect to SMTP servers", | ||
@@ -27,3 +27,3 @@ "main": "lib/smtp-connection.js", | ||
"chai": "^3.5.0", | ||
"grunt": "^0.4.5", | ||
"grunt": "^1.0.1", | ||
"grunt-eslint": "^18.0.0", | ||
@@ -34,3 +34,3 @@ "grunt-mocha-test": "^0.12.7", | ||
"sinon": "^1.17.3", | ||
"smtp-server": "^1.8.0", | ||
"smtp-server": "^1.9.0", | ||
"xoauth2": "^1.1.0" | ||
@@ -37,0 +37,0 @@ }, |
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
52466
1139