Socket
Socket
Sign inDemoInstall

smtp-server

Package Overview
Dependencies
Maintainers
1
Versions
66
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.8.0 to 1.9.0-beta.0

4

CHANGELOG.md
# Changelog
## v1.9.0-beta.0 2016-02-05
* Added new connection method `onClose`
## v1.8.0-beta.0 2016-01-26

@@ -4,0 +8,0 @@

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

this._server.logger.info('[%s] Connection closed to %s', this._id, this.clientHostname || this.remoteAddress);
setImmediate(this._server.onClose.bind(this._server, this.session));
};

@@ -233,0 +234,0 @@

@@ -66,3 +66,3 @@ 'use strict';

// apply shorthand handlers
['onConnect', 'onAuth', 'onMailFrom', 'onRcptTo', 'onData'].forEach(function (handler) {
['onConnect', 'onAuth', 'onMailFrom', 'onRcptTo', 'onData', 'onClose'].forEach(function (handler) {
if (typeof this.options[handler] === 'function') {

@@ -187,2 +187,6 @@ this[handler] = this.options[handler];

SMTPServer.prototype.onClose = function ( /* session */ ) {
// do nothing
};
// PRIVATE METHODS

@@ -189,0 +193,0 @@

8

package.json
{
"name": "smtp-server",
"version": "1.8.0",
"version": "1.9.0-beta.0",
"description": "Create custom SMTP servers on the fly",

@@ -16,8 +16,8 @@ "main": "lib/smtp-server.js",

"devDependencies": {
"chai": "^3.4.1",
"chai": "^3.5.0",
"grunt": "^0.4.5",
"grunt-eslint": "^17.3.1",
"grunt-mocha-test": "^0.12.7",
"mocha": "^2.3.4",
"smtp-connection": "^2.0.1"
"mocha": "^2.4.5",
"smtp-connection": "^2.1.0"
},

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

@@ -53,2 +53,3 @@ # smtp-server

* **options.onData** is the callback to handle incoming messages (see details [here](#processing-incoming-message))
* **options.onClose** is the callback that informs about closed client connection

@@ -226,2 +227,10 @@ Additionally you can use the options from [net.createServer](http://nodejs.org/api/net.html#net_net_createserver_options_connectionlistener) and [tls.createServer](http://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener) (applies if `secure` is set to true)

If you also need to detect when a connection is closed use `onClose`. This method does not expect you to run a callback function as it is purely informational.
```javascript
var server = new SMTPServer({
onClose: function(session){}
});
```
## Validating sender addresses

@@ -228,0 +237,0 @@

@@ -1157,2 +1157,38 @@ /* eslint no-unused-expressions:0 */

});
describe('onClose handler', function () {
var PORT = 1336;
it('should detect once a connection is closed', function (done) {
var closed = 0;
var total = 50;
var server = new SMTPServer({
logger: false,
onClose: function (session) {
expect(session).to.exist;
expect(closed).to.be.lt(total);
if (++closed >= total) {
server.close(done);
}
}
});
server.listen(PORT, '127.0.0.1', function () {
var createConnection = function () {
var connection = new Client({
port: PORT,
host: '127.0.0.1',
ignoreTLS: true
});
connection.connect(function () {
setTimeout(connection.quit.bind(connection), 100);
});
};
for (var i = 0; i < total; i++) {
createConnection();
}
});
});
});
});
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