Socket
Socket
Sign inDemoInstall

smtp-connection

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smtp-connection - npm Package Compare versions

Comparing version 2.7.0 to 2.8.0

5

CHANGELOG.md
# Changelog
## v2.8.0 2016-07-07
* Added full LMTP support. Set `lmtp` option to `true` to switch into LMTP mode
* Updated default timeout values
## v2.7.0 2016-07-06

@@ -4,0 +9,0 @@

61

lib/smtp-connection.js

@@ -15,2 +15,7 @@ 'use strict';

// default timeout values in ms
var CONNECTION_TIMEOUT = 2 * 60 * 1000; // how much to wait for the connection to be established
var SOCKET_TIMEOUT = 10 * 60 * 1000; // how much to wait for socket inactivity before disconnecting the client
var GREETING_TIMEOUT = 30 * 1000; // how much to wait after connection is established but SMTP greeting is not receieved
module.exports = SMTPConnection;

@@ -221,3 +226,3 @@

this._onError('Connection timeout', 'ETIMEDOUT', false, 'CONN');
}.bind(this), this.options.connectionTimeout || 60 * 1000);
}.bind(this), this.options.connectionTimeout || CONNECTION_TIMEOUT);

@@ -411,3 +416,3 @@ this._socket.on('error', function (err) {

this._socket.setTimeout(this.options.socketTimeout || (10 * 60 * 1000)); // 10 min.
this._socket.setTimeout(this.options.socketTimeout || SOCKET_TIMEOUT);
this._socket.on('timeout', this._onTimeout.bind(this));

@@ -420,3 +425,3 @@

}
}.bind(this), this.options.greetingTimeout || 10000);
}.bind(this), this.options.greetingTimeout || GREETING_TIMEOUT);

@@ -598,3 +603,3 @@ this._responseActions.push(this._actionGreeting);

this._socket.setTimeout(this.options.socketTimeout || (10 * 60 * 1000)); // 10 min.
this._socket.setTimeout(this.options.socketTimeout || SOCKET_TIMEOUT); // 10 min.
this._socket.on('timeout', this._onTimeout.bind(this));

@@ -806,5 +811,14 @@

this._responseActions.push(function (str) {
this._actionStream(str, callback);
}.bind(this));
if (this.options.lmtp) {
this._envelope.accepted.forEach(function (recipient, i) {
var final = i === this._envelope.accepted.length - 1;
this._responseActions.push(function (str) {
this._actionLMTPStream(recipient, final, str, callback);
}.bind(this));
}.bind(this));
} else {
this._responseActions.push(function (str) {
this._actionSMTPStream(str, callback);
}.bind(this));
}

@@ -1288,7 +1302,8 @@ dataStream.pipe(this._socket, {

/**
* Handle response for a DATA stream
* Handle response for a DATA stream when using SMTP
* We expect a single response that defines if the sending succeeded or failed
*
* @param {String} str Message from the server
*/
SMTPConnection.prototype._actionStream = function (str, callback) {
SMTPConnection.prototype._actionSMTPStream = function (str, callback) {
if (Number(str.charAt(0)) !== 2) {

@@ -1303,2 +1318,30 @@ // Message failed

/**
* Handle response for a DATA stream
* We expect a separate response for every recipient. All recipients can either
* succeed or fail separately
*
* @param {String} recipient The recipient this response applies to
* @param {Boolean} final Is this the final recipient?
* @param {String} str Message from the server
*/
SMTPConnection.prototype._actionLMTPStream = function (recipient, final, str, callback) {
var err;
if (Number(str.charAt(0)) !== 2) {
// Message failed
err = this._formatError('Message failed for recipient ' + recipient, 'EMESSAGE', str, 'DATA');
err.recipient = recipient;
this._envelope.rejected.push(recipient);
this._envelope.rejectedErrors.push(err);
for (var i = 0, len = this._envelope.accepted.length; i < len; i++) {
if (this._envelope.accepted[i] === recipient) {
this._envelope.accepted.splice(i, 1);
}
}
}
if (final) {
return callback(null, str);
}
};
SMTPConnection.prototype._handleXOauth2Token = function (isRetry, callback) {

@@ -1305,0 +1348,0 @@ this._responseActions.push(function (str) {

4

package.json
{
"name": "smtp-connection",
"version": "2.7.0",
"version": "2.8.0",
"description": "Connect to SMTP servers",

@@ -34,3 +34,3 @@ "main": "lib/smtp-connection.js",

"sinon": "^1.17.4",
"smtp-server": "^1.10.0",
"smtp-server": "^1.11.0",
"xoauth2": "^1.1.0"

@@ -37,0 +37,0 @@ },

@@ -34,2 +34,3 @@ # smtp-connection

* **options.requireTLS** forces the client to use STARTTLS. Returns an error if upgrading the connection is not possible or fails.
* **options.lmtp** if true, uses LMTP instead of SMTP to talk to the server
* **options.name** optional hostname of the client, used for identifying to the server

@@ -42,3 +43,2 @@ * **options.localAddress** is the local interface to bind to for network connections

* **options.debug** if set to true, then logs SMTP traffic, otherwise logs only transaction events
* **options.lmtp** if true, uses LMTP instead of SMTP to talk to the server. Partial support, does not work well with multiple recipients
* **options.authMethod** defines preferred authentication method, e.g. 'PLAIN'

@@ -156,4 +156,4 @@ * **options.tls** defines additional options to be passed to the socket constructor, e.g. *{rejectUnauthorized: true}*

* **info** information object about accepted and rejected recipients
* **accepted** an array of accepted recipient addresses
* **rejected** an array of rejected recipient addresses
* **accepted** an array of accepted recipient addresses. Normally this array should contain at least one address except when in LMTP mode. In this case the message itself might have succeeded but all recipients were rejected after sending the message.
* **rejected** an array of rejected recipient addresses. This array includes both the addresses that were rejected before sending the message and addresses rejected after sending it if using LMTP
* **rejectedErrors** if some recipients were rejected then this property holds an array of error objects for the rejected recipients

@@ -160,0 +160,0 @@ * **response** is the last response received from the server

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc