diff --git a/lib/smtp-connection.js b/lib/smtp-connection.js index e3daf31..4c243b1 100644 --- a/lib/smtp-connection.js +++ b/lib/smtp-connection.js @@ -247,6 +247,10 @@ class SMTPConnection extends EventEmitter { .join(' '); } + if (code >= 400) { + this.session.error = payload; + } + if (this._socket && this._socket.writable) { this._socket.write(payload + '\r\n'); this._server.logger.debug( @@ -346,6 +350,7 @@ class SMTPConnection extends EventEmitter { return; } + err.remote = this.remoteAddress this._server.logger.error( { err, diff --git a/lib/smtp-server.js b/lib/smtp-server.js index afab6fa..c5ba56b 100644 --- a/lib/smtp-server.js +++ b/lib/smtp-server.js @@ -170,6 +170,11 @@ class SMTPServer extends EventEmitter { connection.close(); }); } + if (typeof callback === 'function') { + const realCallback = callback; + callback = null; + return realCallback(); + } }, timeout); } diff --git a/test/smtp-stream-test.js b/test/smtp-stream-test.js index af941c8..69a6021 100644 --- a/test/smtp-stream-test.js +++ b/test/smtp-stream-test.js @@ -1,5 +1,5 @@ /* eslint no-unused-expressions:0, prefer-arrow-callback: 0 */ -/* globals beforeEach, describe, it */ +/* globals describe, it */ 'use strict';