Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smtp-server

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smtp-server - npm Package Compare versions

Comparing version 1.14.2 to 1.15.0

5

CHANGELOG.md
# Changelog
## v1.15.0 2016-09-23
* Added new connection property `remotePort`
* Emit 'connect' event when all handshakes (including PROXY) have been completed
## v1.14.2 2016-09-02

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

71

lib/smtp-connection.js

@@ -69,2 +69,3 @@ 'use strict';

this.remoteAddress = (this._socket.remoteAddress || '').replace(/^::ffff:/, '');
this.remotePort = Number(this._socket.remotePort) || 0;

@@ -100,2 +101,5 @@ // normalize IPv6 addresses

// if true then can emit connection info
this._canEmitConnection = true;
// increment connection count

@@ -148,2 +152,7 @@ this._closing = false;

this._ready = true; // Start accepting data from input
if (!this._server.options.useXClient && !this._server.options.useXForward) {
this.emitConnection();
}
this._server.logger.info('[%s] Connection from %s', this._id, this.clientHostname);

@@ -305,2 +314,6 @@ this.send(220, this.name + ' ' + (this._server.options.lmtp ? 'LMTP' : 'ESMTP') + (this._server.options.banner ? ' ' + this._server.options.banner : ''));

this.remoteAddress = params[1].trim().toLowerCase();
if (params[3]) {
this.remotePort = Number(params[3].trim()) || this.remotePort;
}
this.emitConnection();
}

@@ -476,2 +489,3 @@

session.remoteAddress = this.remoteAddress;
session.remotePort = this.remotePort;
session.clientHostname = this.clientHostname;

@@ -518,2 +532,15 @@ session.openingCommand = this.openingCommand;

SMTPConnection.prototype.emitConnection = function () {
if (!this._canEmitConnection) {
return;
}
this._canEmitConnection = false;
this.emit('connect', {
remoteAddress: this.remoteAddress,
remotePort: this.remotePort,
hostNameAppearsAs: this.hostNameAppearsAs,
clientHostname: this.clientHostname
});
};
// COMMAND HANDLERS

@@ -734,2 +761,13 @@

break;
case 'PORT':
value = Number(value) || '';
this._server.logger.info('[%s] XCLIENT remote port resolved as "%s"', this._id, value);
// store original value for reference as NAME:DEFAULT
if (!this._xClient.has('PORT:DEFAULT')) {
this._xClient.set('PORT:DEFAULT', this.remotePort || '');
}
this.remotePort = value;
break;
default:

@@ -746,2 +784,6 @@ // other values are not relevant

if (data.has('ADDR')) {
this.emitConnection();
}
// success

@@ -775,2 +817,3 @@ this.send(220, this.name + ' ' + (this._server.options.lmtp ? 'LMTP' : 'ESMTP') + (this._server.options.banner ? ' ' + this._server.options.banner : ''));

var data = new Map();
var hasAddr = false;
parts.shift(); // remove XFORWARD prefix

@@ -823,2 +866,10 @@

this._server.logger.info('[%s] XFORWARD from %s through %s', this._id, value, this.remoteAddress);
// store original value for reference as ADDR:DEFAULT
if (!this._xClient.has('ADDR:DEFAULT')) {
this._xClient.set('ADDR:DEFAULT', this.remoteAddress);
}
hasAddr = true;
this.remoteAddress = value;
}

@@ -829,3 +880,14 @@ break;

this._server.logger.info('[%s] XFORWARD hostname resolved as "%s"', this._id, value);
this.clientHostname = value.toLowerCase();
break;
case 'PORT':
value = Number(value) || 0;
this._server.logger.info('[%s] XFORWARD port resolved as "%s"', this._id, value);
this.remotePort = value;
break;
case 'HELO':
value = Number(value) || 0;
this._server.logger.info('[%s] XFORWARD HELO name resolved as "%s"', this._id, value);
this.hostNameAppearsAs = value;
break;
default:

@@ -837,2 +899,7 @@ // other values are not relevant

if (hasAddr) {
this._canEmitConnection = true;
this.emitConnection();
}
// success

@@ -937,2 +1004,5 @@ this.send(250, 'OK');

// in case we still haven't informed about the new connection emit it
this.emitConnection();
// sender address can be empty, so we only check if parsing failed or not

@@ -967,3 +1037,2 @@ if (!parsed) {

/**

@@ -970,0 +1039,0 @@ * Processes RCPT TO command, parses address and extra arguments

@@ -87,2 +87,3 @@ 'use strict';

connection.on('error', this._onError.bind(this));
connection.on('connect', this._onClientConnect.bind(this));
connection.init();

@@ -235,1 +236,10 @@ }.bind(this));

};
/**
* Called when a new connection is established. This might not be the same time the socket is opened
*
* @event
*/
SMTPServer.prototype._onClientConnect = function (data) {
this.emit('connect', data);
};

8

package.json
{
"name": "smtp-server",
"version": "1.14.2",
"version": "1.15.0",
"description": "Create custom SMTP servers on the fly",

@@ -13,3 +13,3 @@ "main": "lib/smtp-server.js",

"ipv6-normalize": "^1.0.1",
"nodemailer-shared": "^1.0.5"
"nodemailer-shared": "^1.1.0"
},

@@ -21,5 +21,5 @@ "devDependencies": {

"grunt-eslint": "^19.0.0",
"grunt-mocha-test": "^0.12.7",
"grunt-mocha-test": "^0.13.2",
"mocha": "^3.0.2",
"smtp-connection": "^2.11.0"
"smtp-connection": "^2.12.0"
},

@@ -26,0 +26,0 @@ "engines": {

@@ -5,2 +5,4 @@ # smtp-server

> **NB!** this module does not make any email deliveries by itself. smtp-server allows you to listen on ports 25/24/465/587/etc using SMTP protocol and that's it. Your own application is responsible of accepting and delivering the message to destination.
[![Build Status](https://secure.travis-ci.org/andris9/smtp-server.svg)](http://travis-ci.org/andris9/Nodemailer)

@@ -11,2 +13,9 @@ [![npm version](https://badge.fury.io/js/smtp-server.svg)](http://badge.fury.io/js/smtp-server)

## Other similar packages you might be interested in
* **[nodemailer](https://github.com/nodemailer/nodemailer)** – all in one package to send email from Node.js
* **[smtp-server](https://github.com/andris9/smtp-server)** – add SMTP server interface to your application
* **[smtp-server](https://github.com/nodemailer/smtp-connection)** – connect to SMTP servers from your application
* **[zone-mta](https://github.com/zone-eu/zone-mta)** – full featured outbound MTA built using smtp-connection and smtp-server modules
## Support smtp-server development

@@ -13,0 +22,0 @@

@@ -1163,2 +1163,3 @@ /* eslint no-unused-expressions:0 */

expect(conn.remoteAddress).to.equal('198.51.100.22');
expect(conn.remotePort).to.equal(35646);
connection.quit();

@@ -1165,0 +1166,0 @@ });

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