CVE-2020-7769: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection') (CWE-88)
value: This affects the package nodemailer before 6.4.16. Use of crafted recipient email addresses may result in arbitrary command flag injection in sendmail transport for sending mails.
CWE description: The product constructs a string for a command to be executed by a separate component
in another control sphere, but it does not properly delimit the
intended arguments, options, or switches within that command string.
CVSS v3 base score: 9.8
Published: 2020-11-12T09:15Z
Repository: https://github.com/nodemailer/nodemailer
Language: JavaScript
Files changed: .travis.yml, Gruntfile.js, lib/dkim/message-parser.js, lib/fetch/cookies.js, lib/fetch/index.js, lib/mailer/mail-message.js, lib/mime-funcs/mime-types.js, lib/nodemailer.js, lib/sendmail-transport/index.js, lib/shared/index.js, lib/smtp-connection/http-proxy-client.js, lib/smtp-connection/index.js, lib/well-known/index.js, lib/well-known/services.json, lib/xoauth2/index.js, package.json, test/base64/base64-test.js, test/dkim/dkim-test.js, test/dkim/message-parser-test.js, test/dkim/relaxed-body-test.js, test/dkim/sign-test.js, test/ethereal-test.js, test/fetch/cookies-test.js, test/fetch/fetch-test.js, test/json-transport/json-transport-test.js, test/qp/qp-test.js, test/sendmail/le-unix.test.js, test/sendmail/le-windows-test.js, test/sendmail/sendmail-test.js, test/ses-transport/ses-transport-test.js, test/shared/shared-test.js, test/smtp-connection/http-proxy-client-test.js, test/smtp-connection/smtp-connection-test.js, test/smtp-connection/xoauth2-mock-server.js, test/smtp-pool/smtp-pool-test.js, test/smtp-transport/smtp-tranport-test.js, test/stream-transport/stream-transport-test.js, test/well-known/well-known-test.js, test/xoauth2/server.js, test/xoauth2/xoauth2-test.js
Commit date: 2020-11-12 10:03:18 +0200
Commit message: v6.4.16

Diff: diff --git a/.travis.yml b/.travis.yml
index 891b8ce..a58016f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,10 +2,11 @@ language: node_js
 sudo: false
 node_js:
     - 10
     - 12
     - 14
+    - 15
 notifications:
     email:
         - andris@kreata.ee
     webhooks:
         urls:
diff --git a/Gruntfile.js b/Gruntfile.js
index 70e8379..4f72c08 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,8 +1,8 @@
 'use strict';
 
-module.exports = function(grunt) {
+module.exports = function (grunt) {
     // Project configuration.
     grunt.initConfig({
         eslint: {
             all: ['index.js', 'lib/**/*.js', 'test/**/*.js', 'examples/**/*.js', 'Gruntfile.js']
         },
diff --git a/lib/dkim/message-parser.js b/lib/dkim/message-parser.js
index 124002e..8ee93d2 100644
--- a/lib/dkim/message-parser.js
+++ b/lib/dkim/message-parser.js
@@ -144,14 +144,11 @@ class MessageParser extends Transform {
             }
         }
         return lines
             .filter(line => line.trim())
             .map(line => ({
-                key: line
-                    .substr(0, line.indexOf(':'))
-                    .trim()
-                    .toLowerCase(),
+                key: line.substr(0, line.indexOf(':')).trim().toLowerCase(),
                 line
             }));
     }
 }
 
diff --git a/lib/fetch/cookies.js b/lib/fetch/cookies.js
index 3fbd988..917b840 100644
--- a/lib/fetch/cookies.js
+++ b/lib/fetch/cookies.js
@@ -108,14 +108,11 @@ class Cookies {
         (cookieStr || '')
             .toString()
             .split(';')
             .forEach(cookiePart => {
                 let valueParts = cookiePart.split('=');
-                let key = valueParts
-                    .shift()
-                    .trim()
-                    .toLowerCase();
+                let key = valueParts.shift().trim().toLowerCase();
                 let value = valueParts.join('=').trim();
                 let domain;
 
                 if (!key) {
                     // skip empty parts
diff --git a/lib/fetch/index.js b/lib/fetch/index.js
index ca7874e..62ffb37 100644
--- a/lib/fetch/index.js
+++ b/lib/fetch/index.js
@@ -8,11 +8,11 @@ const PassThrough = require('stream').PassThrough;
 const Cookies = require('./cookies');
 const packageData = require('../../package.json');
 
 const MAX_REDIRECTS = 5;
 
-module.exports = function(url, options) {
+module.exports = function (url, options) {
     return fetch(url, options);
 };
 
 module.exports.Cookies = Cookies;
 
@@ -31,15 +31,11 @@ function fetch(url, options) {
         options.cookie = false;
     }
 
     let fetchRes = options.fetchRes;
     let parsed = urllib.parse(url);
-    let method =
-        (options.method || '')
-            .toString()
-            .trim()
-            .toUpperCase() || 'GET';
+    let method = (options.method || '').toString().trim().toUpperCase() || 'GET';
     let finished = false;
     let cookies;
     let body;
 
     let handler = parsed.protocol === 'https:' ? https : http;
@@ -113,15 +109,11 @@ function fetch(url, options) {
 
             headers['Content-Type'] = options.contentType || 'application/x-www-form-urlencoded';
             headers['Content-Length'] = body.length;
         }
         // if method is not provided, use POST instead of GET
-        method =
-            (options.method || '')
-                .toString()
-                .trim()
-                .toUpperCase() || 'POST';
+        method = (options.method || '').toString().trim().toUpperCase() || 'POST';
     }
 
     let req;
     let reqOptions = {
         method,
diff --git a/lib/mailer/mail-message.js b/lib/mailer/mail-message.js
index 787ffe7..16adb7c 100644
--- a/lib/mailer/mail-message.js
+++ b/lib/mailer/mail-message.js
@@ -62,16 +62,11 @@ class MailMessage {
         }
 
         if (this.data.attachments && this.data.attachments.length) {
             this.data.attachments.forEach((attachment, i) => {
                 if (!attachment.filename) {
-                    attachment.filename =
-                        (attachment.path || attachment.href || '')
-                            .split('/')
-                            .pop()
-                            .split('?')
-                            .shift() || 'attachment-' + (i + 1);
+                    attachment.filename = (attachment.path || attachment.href || '').split('/').pop().split('?').shift() || 'attachment-' + (i + 1);
                     if (attachment.filename.indexOf('.') < 0) {
                         attachment.filename += '.' + mimeFuncs.detectExtension(attachment.contentType);
                     }
                 }
 
diff --git a/lib/mime-funcs/mime-types.js b/lib/mime-funcs/mime-types.js
index 85f7be6..64fa081 100644
--- a/lib/mime-funcs/mime-types.js
+++ b/lib/mime-funcs/mime-types.js
@@ -2061,15 +2061,11 @@ module.exports = {
         if (!filename) {
             return defaultMimeType;
         }
 
         let parsed = path.parse(filename);
-        let extension = (parsed.ext.substr(1) || parsed.name || '')
-            .split('?')
-            .shift()
-            .trim()
-            .toLowerCase();
+        let extension = (parsed.ext.substr(1) || parsed.name || '').split('?').shift().trim().toLowerCase();
         let value = defaultMimeType;
 
         if (extensions.has(extension)) {
             value = extensions.get(extension);
         }
@@ -2082,14 +2078,11 @@ module.exports = {
 
     detectExtension(mimeType) {
         if (!mimeType) {
             return defaultExtension;
         }
-        let parts = (mimeType || '')
-            .toLowerCase()
-            .trim()
-            .split('/');
+        let parts = (mimeType || '').toLowerCase().trim().split('/');
         let rootType = parts.shift().trim();
         let subType = parts.join('/').trim();
 
         if (mimeTypes.has(rootType + '/' + subType)) {
             let value = mimeTypes.get(rootType + '/' + subType);
diff --git a/lib/nodemailer.js b/lib/nodemailer.js
index 85a7fa4..8f63e42 100644
--- a/lib/nodemailer.js
+++ b/lib/nodemailer.js
@@ -11,20 +11,15 @@ const SESTransport = require('./ses-transport');
 const fetch = require('./fetch');
 const packageData = require('../package.json');
 
 const ETHEREAL_API = (process.env.ETHEREAL_API || 'https://api.nodemailer.com').replace(/\/+$/, '');
 const ETHEREAL_WEB = (process.env.ETHEREAL_WEB || 'https://ethereal.email').replace(/\/+$/, '');
-const ETHEREAL_CACHE = ['true', 'yes', 'y', '1'].includes(
-    (process.env.ETHEREAL_CACHE || 'yes')
-        .toString()
-        .trim()
-        .toLowerCase()
-);
+const ETHEREAL_CACHE = ['true', 'yes', 'y', '1'].includes((process.env.ETHEREAL_CACHE || 'yes').toString().trim().toLowerCase());
 
 let testAccount = false;
 
-module.exports.createTransport = function(transporter, defaults) {
+module.exports.createTransport = function (transporter, defaults) {
     let urlConfig;
     let options;
     let mailer;
 
     if (
@@ -58,11 +53,11 @@ module.exports.createTransport = function(transporter, defaults) {
     mailer = new Mailer(transporter, options, defaults);
 
     return mailer;
 };
 
-module.exports.createTestAccount = function(apiUrl, callback) {
+module.exports.createTestAccount = function (apiUrl, callback) {
     let promise;
 
     if (!callback && typeof apiUrl === 'function') {
         callback = apiUrl;
         apiUrl = false;
@@ -126,11 +121,11 @@ module.exports.createTestAccount = function(apiUrl, callback) {
     });
 
     return promise;
 };
 
-module.exports.getTestMessageUrl = function(info) {
+module.exports.getTestMessageUrl = function (info) {
     if (!info || !info.response) {
         return false;
     }
 
     let infoProps = new Map();
diff --git a/lib/sendmail-transport/index.js b/lib/sendmail-transport/index.js
index 0e59221..cce15e7 100644
--- a/lib/sendmail-transport/index.js
+++ b/lib/sendmail-transport/index.js
@@ -68,10 +68,18 @@ class SendmailTransport {
         let args;
         let sendmail;
         let returned;
         let transform;
 
+        const hasInvalidAddresses = []
+            .concat(envelope.from || [])
+            .concat(envelope.to || [])
+            .some(addr => /^-/.test(addr));
+        if (hasInvalidAddresses) {
+            return done(new Error('Can not send mail. Invalid envelope addresses.'));
+        }
+
         if (this.args) {
             // force -i to keep single dots
             args = ['-i'].concat(this.args).concat(envelope.to);
         } else {
             args = ['-i'].concat(envelope.from ? ['-f', envelope.from] : []).concat(envelope.to);
diff --git a/lib/shared/index.js b/lib/shared/index.js
index b2571c1..cecafba 100644
--- a/lib/shared/index.js
+++ b/lib/shared/index.js
@@ -274,11 +274,11 @@ module.exports.getLogger = (options, defaults) => {
  *
  * @param {Function} resolve Function to run if callback is called
  * @param {Function} reject Function to run if callback ends with an error
  */
 module.exports.callbackPromise = (resolve, reject) =>
-    function() {
+    function () {
         let args = Array.from(arguments);
         let err = args.shift();
         if (err) {
             reject(err);
         } else {
@@ -355,11 +355,11 @@ module.exports.resolveContent = (data, key, callback) => {
 };
 
 /**
  * Copies properties from source objects to target objects
  */
-module.exports.assign = function(/* target, ... sources */) {
+module.exports.assign = function (/* target, ... sources */) {
     let args = Array.from(arguments);
     let target = args.shift() || {};
 
     args.forEach(source => {
         Object.keys(source || {}).forEach(key => {
@@ -487,19 +487,11 @@ function createDefaultLogger(levels) {
             }
         }
 
         message = util.format(message, ...args);
         message.split(/\r?\n/).forEach(line => {
-            console.log(
-                '[%s] %s %s',
-                new Date()
-                    .toISOString()
-                    .substr(0, 19)
-                    .replace(/T/, ' '),
-                levelNames.get(level),
-                prefix + line
-            );
+            console.log('[%s] %s %s', new Date().toISOString().substr(0, 19).replace(/T/, ' '), levelNames.get(level), prefix + line);
         });
     };
 
     let logger = {};
     levels.forEach(level => {
diff --git a/lib/smtp-connection/http-proxy-client.js b/lib/smtp-connection/http-proxy-client.js
index efb2503..0610dc1 100644
--- a/lib/smtp-connection/http-proxy-client.js
+++ b/lib/smtp-connection/http-proxy-client.js
@@ -42,11 +42,11 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, callback) {
     }
 
     // Error harness for initial connection. Once connection is established, the responsibility
     // to handle errors is passed to whoever uses this socket
     let finished = false;
-    let tempSocketErr = function(err) {
+    let tempSocketErr = function (err) {
         if (finished) {
             return;
         }
         finished = true;
         try {
diff --git a/lib/smtp-connection/index.js b/lib/smtp-connection/index.js
index 4db05e1..2ad9b17 100644
--- a/lib/smtp-connection/index.js
+++ b/lib/smtp-connection/index.js
@@ -43,14 +43,11 @@ const GREETING_TIMEOUT = 30 * 1000; // how much to wait after connection is esta
  */
 class SMTPConnection extends EventEmitter {
     constructor(options) {
         super(options);
 
-        this.id = crypto
-            .randomBytes(8)
-            .toString('base64')
-            .replace(/\W/g, '');
+        this.id = crypto.randomBytes(8).toString('base64').replace(/\W/g, '');
         this.stage = 'init';
 
         this.options = options || {};
 
         this.secureConnection = !!this.options.secure;
@@ -71,14 +68,11 @@ class SMTPConnection extends EventEmitter {
             sid: this.id
         });
 
         this.customAuth = new Map();
         Object.keys(this.options.customAuth || {}).forEach(key => {
-            let mapKey = (key || '')
-                .toString()
-                .trim()
-                .toUpperCase();
+            let mapKey = (key || '').toString().trim().toUpperCase();
             if (!mapKey) {
                 return;
             }
             this.customAuth.set(mapKey, this.options.customAuth[key]);
         });
@@ -422,15 +416,11 @@ class SMTPConnection extends EventEmitter {
             return callback(this._formatError(isDestroyedMessage, 'ECONNECTION', false, 'API'));
         }
 
         this._auth = authData || {};
         // Select SASL authentication method
-        this._authMethod =
-            (this._auth.method || '')
-                .toString()
-                .trim()
-                .toUpperCase() || false;
+        this._authMethod = (this._auth.method || '').toString().trim().toUpperCase() || false;
 
         if (!this._authMethod && this._auth.oauth2 && !this._auth.credentials) {
             this._authMethod = 'XOAUTH2';
         } else if (!this._authMethod || (this._authMethod === 'XOAUTH2' && !this._auth.oauth2)) {
             // use first supported
@@ -596,11 +586,11 @@ class SMTPConnection extends EventEmitter {
             });
         }
 
         // ensure that callback is only called once
         let returned = false;
-        let callback = function() {
+        let callback = function () {
             if (returned) {
                 return;
             }
             returned = true;
 
diff --git a/lib/well-known/index.js b/lib/well-known/index.js
index ca4c537..9fdc28f 100644
--- a/lib/well-known/index.js
+++ b/lib/well-known/index.js
@@ -39,9 +39,9 @@ function normalizeService(service) {
  * an email address (like 'test@googlemail.com').
  *
  * @param {String} key [description]
  * @returns {Object} SMTP config or false if not found
  */
-module.exports = function(key) {
+module.exports = function (key) {
     key = normalizeKey(key.split('@').pop());
     return normalized[key] || false;
 };
diff --git a/lib/well-known/services.json b/lib/well-known/services.json
index a758728..9342367 100644
--- a/lib/well-known/services.json
+++ b/lib/well-known/services.json
@@ -20,14 +20,14 @@
     "DynectEmail": {
         "aliases": ["Dynect"],
         "host": "smtp.dynect.net",
         "port": 25
     },
-    
+
     "Ethereal": {
         "aliases": ["ethereal.email"],
-        "host": "smtp.ethereal.email",   
+        "host": "smtp.ethereal.email",
         "port": 587
     },
 
     "FastMail": {
         "domains": ["fastmail.fm"],
diff --git a/lib/xoauth2/index.js b/lib/xoauth2/index.js
index d92c25e..e4e2f4e 100644
--- a/lib/xoauth2/index.js
+++ b/lib/xoauth2/index.js
@@ -261,15 +261,15 @@ class XOAuth2 extends Stream {
             );
 
             if (data.error) {
                 // Error Response : https://tools.ietf.org/html/rfc6749#section-5.2
                 let errorMessage = data.error;
-                if(data.error_description) {
-                  errorMessage += ': ' + data.error_description;
+                if (data.error_description) {
+                    errorMessage += ': ' + data.error_description;
                 }
-                if(data.error_uri) {
-                  errorMessage += ' (' + data.error_uri + ')';
+                if (data.error_uri) {
+                    errorMessage += ' (' + data.error_uri + ')';
                 }
                 return callback(new Error(errorMessage));
             }
 
             if (data.access_token) {
diff --git a/package.json b/package.json
index dd8331a..bc1b90c 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,8 @@
 {
     "name": "nodemailer",
-    "version": "6.4.15",
+    "version": "6.4.16",
     "description": "Easy as cake e-mail sending from your Node.js applications",
     "main": "lib/nodemailer.js",
     "scripts": {
         "test": "grunt"
     },
diff --git a/test/base64/base64-test.js b/test/base64/base64-test.js
index 950fa65..588c9a7 100644
--- a/test/base64/base64-test.js
+++ b/test/base64/base64-test.js
@@ -10,11 +10,11 @@ const expect = chai.expect;
 const crypto = require('crypto');
 const fs = require('fs');
 
 chai.config.includeStack = true;
 
-describe('Base64 Tests', function() {
+describe('Base64 Tests', function () {
     let encodeFixtures = [
         ['abcd= ÕÄÖÜ', 'YWJjZD0gw5XDhMOWw5w='],
         ['foo bar  ', 'Zm9vIGJhciAg'],
         ['foo bar\t\t', 'Zm9vIGJhcgkJ'],
         ['foo \r\nbar', 'Zm9vIA0KYmFy']
@@ -25,58 +25,58 @@ describe('Base64 Tests', function() {
     let streamFixture = [
         '123456789012345678  90\r\nõäöüõäöüõäöüõäöüõäöüõäöüõäöüõäöü another line === ',
         'MTIzNDU2N\r\nzg5MDEyMz\r\nQ1Njc4ICA\r\n5MA0Kw7XD\r\npMO2w7zDt\r\ncOkw7bDvM\r\nO1w6TDtsO\r\n8w7XDpMO2\r\nw7zDtcOkw\r\n7bDvMO1w6\r\nTDtsO8w7X\r\nDpMO2w7zD\r\ntcOkw7bDv\r\nCBhbm90aG\r\nVyIGxpbmU\r\ngPT09IA=='
     ];
 
-    describe('#encode', function() {
-        it('shoud encode UTF-8 string to base64', function() {
-            encodeFixtures.forEach(function(test) {
+    describe('#encode', function () {
+        it('shoud encode UTF-8 string to base64', function () {
+            encodeFixtures.forEach(function (test) {
                 expect(base64.encode(test[0])).to.equal(test[1]);
             });
         });
 
-        it('shoud encode Buffer to base64', function() {
+        it('shoud encode Buffer to base64', function () {
             expect(base64.encode(Buffer.from([0x00, 0x01, 0x02, 0x20, 0x03]))).to.equal('AAECIAM=');
         });
     });
 
-    describe('#wrap', function() {
-        it('should wrap long base64 encoded lines', function() {
-            wrapFixtures.forEach(function(test) {
+    describe('#wrap', function () {
+        it('should wrap long base64 encoded lines', function () {
+            wrapFixtures.forEach(function (test) {
                 expect(base64.wrap(test[0], 20)).to.equal(test[1]);
             });
         });
     });
 
-    describe('base64 Streams', function() {
-        it('should transform incoming bytes to base64', function(done) {
+    describe('base64 Streams', function () {
+        it('should transform incoming bytes to base64', function (done) {
             let encoder = new base64.Encoder({
                 lineLength: 9
             });
 
             let bytes = Buffer.from(streamFixture[0]),
                 i = 0,
                 buf = [],
                 buflen = 0;
 
-            encoder.on('data', function(chunk) {
+            encoder.on('data', function (chunk) {
                 buf.push(chunk);
                 buflen += chunk.length;
             });
 
-            encoder.on('end', function(chunk) {
+            encoder.on('end', function (chunk) {
                 if (chunk) {
                     buf.push(chunk);
                     buflen += chunk.length;
                 }
                 buf = Buffer.concat(buf, buflen);
 
                 expect(buf.toString()).to.equal(streamFixture[1]);
                 done();
             });
 
-            let sendNextByte = function() {
+            let sendNextByte = function () {
                 if (i >= bytes.length) {
                     return encoder.end();
                 }
 
                 let ord = bytes[i++];
@@ -85,33 +85,33 @@ describe('Base64 Tests', function() {
             };
 
             sendNextByte();
         });
 
-        it('should transform incoming bytes to base64 and back', function(done) {
+        it('should transform incoming bytes to base64 and back', function (done) {
             let decoder = new libbase64.Decoder();
             let encoder = new base64.Encoder();
             let file = fs.createReadStream(__dirname + '/fixtures/alice.txt');
 
             let fhash = crypto.createHash('md5');
             let dhash = crypto.createHash('md5');
 
             file.pipe(encoder).pipe(decoder);
 
-            file.on('data', function(chunk) {
+            file.on('data', function (chunk) {
                 fhash.update(chunk);
             });
 
-            file.on('end', function() {
+            file.on('end', function () {
                 fhash = fhash.digest('hex');
             });
 
-            decoder.on('data', function(chunk) {
+            decoder.on('data', function (chunk) {
                 dhash.update(chunk);
             });
 
-            decoder.on('end', function() {
+            decoder.on('end', function () {
                 dhash = dhash.digest('hex');
                 expect(fhash).to.equal(dhash);
                 done();
             });
         });
diff --git a/test/dkim/dkim-test.js b/test/dkim/dkim-test.js
index fc1716a..07e3874 100644
--- a/test/dkim/dkim-test.js
+++ b/test/dkim/dkim-test.js
@@ -32,14 +32,14 @@ MHwwDQYJKoZIhvcNAQEBBQADawAwaAJhANCx7ncKUfQ8wBUYmMqq6ky8rBB0NL8k
 nBf3+uA7q/CSxpX6sQ8NdFNtEeEd7gu7BWEM7+PkO1P0M78eZOvVmput8BP9R44A
 RpgHY4V0qSCdUt4rD32nwfjlGbh8p5ua5wIDAQAB
 -----END PUBLIC KEY-----`;
 */
 
-describe('DKIM Tests', function() {
+describe('DKIM Tests', function () {
     this.timeout(100 * 1000); // eslint-disable-line
 
-    it('should sign message', function(done) {
+    it('should sign message', function (done) {
         let message = `From: saatja aadress
 To: Saaja aadress
 Subject: pealkiri
   mitmel
   real
@@ -108,11 +108,11 @@ teine rida
             setImmediate(writeNext);
         };
         writeNext();
     });
 
-    it('should sign large message using cache dir', function(done) {
+    it('should sign large message using cache dir', function (done) {
         let dkim = new DKIM({
             domainName: 'node.ee',
             keySelector: 'dkim',
             privateKey,
             cacheDir: path.join(__dirname, 'cache')
@@ -156,11 +156,11 @@ teine rida
             expect(output.usingCache).to.be.true;
             done();
         });
     });
 
-    it('should sign large message without cache dir', function(done) {
+    it('should sign large message without cache dir', function (done) {
         let dkim = new DKIM({
             domainName: 'node.ee',
             keySelector: 'dkim',
             privateKey
         });
@@ -203,11 +203,11 @@ teine rida
             expect(output.usingCache).to.be.false;
             done();
         });
     });
 
-    it('should emit cache error', function(done) {
+    it('should emit cache error', function (done) {
         let dkim = new DKIM({
             domainName: 'node.ee',
             keySelector: 'dkim',
             privateKey,
             cacheDir: '/rootertewywrtyreetwert' // expecting that this location does not exist or is unwritable
@@ -218,11 +218,11 @@ teine rida
             expect(err).to.exist;
             done();
         });
     });
 
-    it('should sign large message as Buffer', function(done) {
+    it('should sign large message as Buffer', function (done) {
         let dkim = new DKIM({
             domainName: 'node.ee',
             keySelector: 'dkim',
             privateKey,
             cacheDir: path.join(__dirname, 'cache')
@@ -266,11 +266,11 @@ teine rida
             expect(output.usingCache).to.be.true;
             done();
         });
     });
 
-    it('should sign large message as String', function(done) {
+    it('should sign large message as String', function (done) {
         let dkim = new DKIM({
             domainName: 'node.ee',
             keySelector: 'dkim',
             privateKey,
             cacheDir: path.join(__dirname, 'cache')
diff --git a/test/dkim/message-parser-test.js b/test/dkim/message-parser-test.js
index 15e8e31..28ee35a 100644
--- a/test/dkim/message-parser-test.js
+++ b/test/dkim/message-parser-test.js
@@ -9,12 +9,12 @@ const expect = chai.expect;
 //let http = require('http');
 const MessageParser = require('../../lib/dkim/message-parser');
 
 chai.config.includeStack = true;
 
-describe('DKIM MessageParser Tests', function() {
-    it('should extract header and body', function(done) {
+describe('DKIM MessageParser Tests', function () {
+    it('should extract header and body', function (done) {
         let parser = new MessageParser();
         let message = `From: saatja aadress
 To: Saaja aadress
 Subject: pealkiri
   mitmel
diff --git a/test/dkim/relaxed-body-test.js b/test/dkim/relaxed-body-test.js
index e881a76..3e6e26b 100644
--- a/test/dkim/relaxed-body-test.js
+++ b/test/dkim/relaxed-body-test.js
@@ -9,12 +9,12 @@ const expect = chai.expect;
 let fs = require('fs');
 let RelaxedBody = require('../../lib/dkim/relaxed-body');
 
 chai.config.includeStack = true;
 
-describe('DKIM RelaxedBody Tests', function() {
-    it('Should calculate body hash byte by byte', function(done) {
+describe('DKIM RelaxedBody Tests', function () {
+    it('Should calculate body hash byte by byte', function (done) {
         fs.readFile(__dirname + '/fixtures/message1.eml', 'utf-8', (err, message) => {
             expect(err).to.not.exist;
 
             message = message.replace(/\r?\n/g, '\r\n');
             message = message.split('\r\n\r\n');
@@ -44,11 +44,11 @@ describe('DKIM RelaxedBody Tests', function() {
             };
             setImmediate(stream);
         });
     });
 
-    it('Should calculate body hash all at once', function(done) {
+    it('Should calculate body hash all at once', function (done) {
         fs.readFile(__dirname + '/fixtures/message1.eml', 'utf-8', (err, message) => {
             expect(err).to.not.exist;
 
             message = message.replace(/\r?\n/g, '\r\n');
             message = message.split('\r\n\r\n');
diff --git a/test/dkim/sign-test.js b/test/dkim/sign-test.js
index 45f3a22..30c29d3 100644
--- a/test/dkim/sign-test.js
+++ b/test/dkim/sign-test.js
@@ -29,12 +29,12 @@ MHwwDQYJKoZIhvcNAQEBBQADawAwaAJhANCx7ncKUfQ8wBUYmMqq6ky8rBB0NL8k
 nBf3+uA7q/CSxpX6sQ8NdFNtEeEd7gu7BWEM7+PkO1P0M78eZOvVmput8BP9R44A
 RpgHY4V0qSCdUt4rD32nwfjlGbh8p5ua5wIDAQAB
 -----END PUBLIC KEY-----`;
 */
 
-describe('DKIM Sign Tests', function() {
-    it('should create relaxed headers', function() {
+describe('DKIM Sign Tests', function () {
+    it('should create relaxed headers', function () {
         let headerLines = [
             {
                 key: 'a',
                 line: 'A: X'
             },
@@ -47,11 +47,11 @@ describe('DKIM Sign Tests', function() {
             headers: 'a:X\r\nb:Y Z\r\n',
             fieldNames: 'a:b'
         });
     });
 
-    it('should skip specific headers', function() {
+    it('should skip specific headers', function () {
         let headerLines = [
             {
                 key: 'a',
                 line: 'A: X'
             },
@@ -72,11 +72,11 @@ describe('DKIM Sign Tests', function() {
             headers: 'b:Y Z\r\nd:X\r\n',
             fieldNames: 'b:d'
         });
     });
 
-    it('should sign headers', function() {
+    it('should sign headers', function () {
         let headerLines = [
             {
                 key: 'from',
                 line: 'From: andris@node.ee'
             },
@@ -99,11 +99,11 @@ describe('DKIM Sign Tests', function() {
         expect(dkimField.replace(/\r?\n\s*/g, '').replace(/\s+/g, '')).to.equal(
             'DKIM-Signature:v=1;a=rsa-sha256;c=relaxed/relaxed;d=node.ee;q=dns/txt;s=dkim;bh=z6TUz85EdYrACGMHYgZhJGvVy5oQI0dooVMKa2ZT7c4=;h=from:to;b=pVd+Dp+EjmYBcc1AWlBAP4ESpuAJ2WMS4gbxWLoeUZ1vZRodVN7K9UXvcCsLuqjJktCZMN2+8dyEUaYW2VIcxg4sVBCS1wqB/tqYZ/gxXLnG2/nZf4fyD2vxltJP4pDL'
         );
     });
 
-    it('should sign headers for unicode domain', function() {
+    it('should sign headers for unicode domain', function () {
         let headerLines = [
             {
                 key: 'from',
                 line: 'From: andris@node.ee'
             },
diff --git a/test/ethereal-test.js b/test/ethereal-test.js
index 9926400..20b996c 100644
--- a/test/ethereal-test.js
+++ b/test/ethereal-test.js
@@ -6,13 +6,13 @@
 const nodemailer = require('../lib/nodemailer');
 const chai = require('chai');
 const expect = chai.expect;
 chai.config.includeStack = true;
 
-describe('Ethereal Tests', function() {
+describe('Ethereal Tests', function () {
     this.timeout(50 * 1000); // eslint-disable-line no-invalid-this
-    it('should create an account and send a message', function(done) {
+    it('should create an account and send a message', function (done) {
         // Generate SMTP service account from ethereal.email
         nodemailer.createTestAccount((err, account) => {
             expect(err).to.not.exist;
             expect(account.user).to.exist;
 
@@ -41,22 +41,22 @@ describe('Ethereal Tests', function() {
                 done();
             });
         });
     });
 
-    it('should cache a created test account', function(done) {
+    it('should cache a created test account', function (done) {
         nodemailer.createTestAccount((err, account) => {
             expect(err).to.not.exist;
             nodemailer.createTestAccount((err, account2) => {
                 expect(err).to.not.exist;
                 expect(account2).to.equal(account);
                 done();
             });
         });
     });
 
-    it('should cache a created test account when using promises', function(done) {
+    it('should cache a created test account when using promises', function (done) {
         nodemailer.createTestAccount().then(account => {
             nodemailer.createTestAccount().then(account2 => {
                 expect(account2).to.equal(account);
                 done();
             });
diff --git a/test/fetch/cookies-test.js b/test/fetch/cookies-test.js
index fe7b46c..987eb2a 100644
--- a/test/fetch/cookies-test.js
+++ b/test/fetch/cookies-test.js
@@ -9,31 +9,31 @@ const expect = chai.expect;
 //let http = require('http');
 const Cookies = require('../../lib/fetch/cookies');
 
 chai.config.includeStack = true;
 
-describe('Cookie Tests', function() {
+describe('Cookie Tests', function () {
     let biskviit;
 
-    beforeEach(function() {
+    beforeEach(function () {
         biskviit = new Cookies();
     });
 
-    describe('#getPath', function() {
-        it('should return root path', function() {
+    describe('#getPath', function () {
+        it('should return root path', function () {
             expect(biskviit.getPath('/')).to.equal('/');
             expect(biskviit.getPath('')).to.equal('/');
             expect(biskviit.getPath('/index.php')).to.equal('/');
         });
 
-        it('should return without file', function() {
+        it('should return without file', function () {
             expect(biskviit.getPath('/path/to/file')).to.equal('/path/to/');
         });
     });
 
-    describe('#isExpired', function() {
-        it('should match expired cookie', function() {
+    describe('#isExpired', function () {
+        it('should match expired cookie', function () {
             expect(
                 biskviit.isExpired({
                     name: 'a',
                     value: 'b',
                     expires: new Date(Date.now() + 10000)
@@ -56,12 +56,12 @@ describe('Cookie Tests', function() {
                 })
             ).to.be.true;
         });
     });
 
-    describe('#compare', function() {
-        it('should match similar cookies', function() {
+    describe('#compare', function () {
+        it('should match similar cookies', function () {
             expect(
                 biskviit.compare(
                     {
                         name: 'zzz',
                         path: '/',
@@ -155,12 +155,12 @@ describe('Cookie Tests', function() {
                 )
             ).to.be.false;
         });
     });
 
-    describe('#add', function() {
-        it('should append new cookie', function() {
+    describe('#add', function () {
+        it('should append new cookie', function () {
             expect(biskviit.cookies.length).to.equal(0);
             biskviit.add({
                 name: 'zzz',
                 value: 'abc',
                 path: '/',
@@ -172,11 +172,11 @@ describe('Cookie Tests', function() {
             expect(biskviit.cookies.length).to.equal(1);
             expect(biskviit.cookies[0].name).to.equal('zzz');
             expect(biskviit.cookies[0].value).to.equal('abc');
         });
 
-        it('should update existing cookie', function() {
+        it('should update existing cookie', function () {
             expect(biskviit.cookies.length).to.equal(0);
             biskviit.add({
                 name: 'zzz',
                 value: 'abc',
                 path: '/',
@@ -198,12 +198,12 @@ describe('Cookie Tests', function() {
             expect(biskviit.cookies[0].name).to.equal('zzz');
             expect(biskviit.cookies[0].value).to.equal('def');
         });
     });
 
-    describe('#match', function() {
-        it('should check if a cookie matches particular domain and path', function() {
+    describe('#match', function () {
+        it('should check if a cookie matches particular domain and path', function () {
             let cookie = {
                 name: 'zzz',
                 value: 'abc',
                 path: '/def/',
                 expires: new Date(Date.now() + 10000),
@@ -213,11 +213,11 @@ describe('Cookie Tests', function() {
             };
             expect(biskviit.match(cookie, 'http://example.com/def/')).to.be.true;
             expect(biskviit.match(cookie, 'http://example.com/bef/')).to.be.false;
         });
 
-        it('should check if a cookie matches particular domain and path', function() {
+        it('should check if a cookie matches particular domain and path', function () {
             let cookie = {
                 name: 'zzz',
                 value: 'abc',
                 path: '/def',
                 expires: new Date(Date.now() + 10000),
@@ -227,11 +227,11 @@ describe('Cookie Tests', function() {
             };
             expect(biskviit.match(cookie, 'http://example.com/def/')).to.be.true;
             expect(biskviit.match(cookie, 'http://example.com/bef/')).to.be.false;
         });
 
-        it('should check if a cookie is secure', function() {
+        it('should check if a cookie is secure', function () {
             let cookie = {
                 name: 'zzz',
                 value: 'abc',
                 path: '/def/',
                 expires: new Date(Date.now() + 10000),
@@ -242,12 +242,12 @@ describe('Cookie Tests', function() {
             expect(biskviit.match(cookie, 'https://example.com/def/')).to.be.true;
             expect(biskviit.match(cookie, 'http://example.com/def/')).to.be.false;
         });
     });
 
-    describe('#parse', function() {
-        it('should parse Set-Cookie value', function() {
+    describe('#parse', function () {
+        it('should parse Set-Cookie value', function () {
             expect(biskviit.parse('theme=plain')).to.deep.equal({
                 name: 'theme',
                 value: 'plain'
             });
 
@@ -260,11 +260,11 @@ describe('Cookie Tests', function() {
                 secure: true,
                 expires: new Date('Wed, 13 Jan 2021 22:23:01 GMT')
             });
         });
 
-        it('should ignore invalid expire header', function() {
+        it('should ignore invalid expire header', function () {
             expect(biskviit.parse('theme=plain; Expires=Wed, 13 Jan 2021 22:23:01 GMT')).to.deep.equal({
                 name: 'theme',
                 value: 'plain',
                 expires: new Date('Wed, 13 Jan 2021 22:23:01 GMT')
             });
@@ -274,12 +274,12 @@ describe('Cookie Tests', function() {
                 value: 'plain'
             });
         });
     });
 
-    describe('Listing', function() {
-        beforeEach(function() {
+    describe('Listing', function () {
+        beforeEach(function () {
             biskviit.cookies = [
                 {
                     name: 'ssid1',
                     value: 'Ap4P….GTEq1',
                     domain: '.foo.com',
@@ -325,12 +325,12 @@ describe('Cookie Tests', function() {
                     expires: new Date('Wed, 13 Jan 2021 22:23:01 GMT')
                 }
             ];
         });
 
-        describe('#list', function() {
-            it('should return matching cookies for an URL', function() {
+        describe('#list', function () {
+            it('should return matching cookies for an URL', function () {
                 expect(biskviit.list('https://www.foo.com')).to.deep.equal([
                     {
                         name: 'ssid1',
                         value: 'Ap4P….GTEq1',
                         domain: '.foo.com',
@@ -350,19 +350,19 @@ describe('Cookie Tests', function() {
                     }
                 ]);
             });
         });
 
-        describe('#get', function() {
-            it('should return matching cookies for an URL', function() {
+        describe('#get', function () {
+            it('should return matching cookies for an URL', function () {
                 expect(biskviit.get('https://www.foo.com')).to.equal('ssid1=Ap4P….GTEq1; ssid4=Ap4P….GTEq4');
             });
         });
     });
 
-    describe('#set', function() {
-        it('should set cookie', function() {
+    describe('#set', function () {
+        it('should set cookie', function () {
             // short
             biskviit.set('theme=plain', 'https://foo.com/');
             // long
             biskviit.set('SSID=Ap4P….GTEq; Domain=foo.com; Path=/test; Expires=Wed, 13 Jan 2021 22:23:01 GMT; Secure; HttpOnly', 'https://foo.com/');
             // subdomains
@@ -376,11 +376,11 @@ describe('Cookie Tests', function() {
             biskviit.set('invalid_4=cors; domain=.co.uk', 'https://foo.co.uk/');
             // should not be added
             biskviit.set('expired_1=date; Expires=1999-01-01 01:01:01 GMT', 'https://foo.com/');
 
             expect(
-                biskviit.cookies.map(function(cookie) {
+                biskviit.cookies.map(function (cookie) {
                     delete cookie.expires;
                     return cookie;
                 })
             ).to.deep.equal([
                 {
diff --git a/test/fetch/fetch-test.js b/test/fetch/fetch-test.js
index f84f396..8b126d7 100644
--- a/test/fetch/fetch-test.js
+++ b/test/fetch/fetch-test.js
@@ -65,15 +65,15 @@ const httpsOptions = {
         'Zwp1dsNQU+Xkylz8IUANWSLHYZOMtN2e5SKIdwTtl5C8YxveuY8YKb1gDExnMraT\n' +
         'VGXQDqPleug=\n' +
         '-----END CERTIFICATE-----'
 };
 
-describe('Fetch Tests', function() {
+describe('Fetch Tests', function () {
     let httpServer, httpsServer;
 
-    beforeEach(function(done) {
-        httpServer = http.createServer(function(req, res) {
+    beforeEach(function (done) {
+        httpServer = http.createServer(function (req, res) {
             switch (req.url) {
                 case '/redirect6':
                     res.writeHead(302, {
                         Location: '/redirect5'
                     });
@@ -162,17 +162,17 @@ describe('Fetch Tests', function() {
                     res.end(req.headers['user-agent']);
                     break;
 
                 case '/post': {
                     let body = [];
-                    req.on('readable', function() {
+                    req.on('readable', function () {
                         let chunk;
                         while ((chunk = req.read()) !== null) {
                             body.push(chunk);
                         }
                     });
-                    req.on('end', function() {
+                    req.on('end', function () {
                         res.writeHead(200, {
                             'Content-Type': 'text/plain'
                         });
                         res.end(Buffer.concat(body));
                     });
@@ -185,298 +185,298 @@ describe('Fetch Tests', function() {
                     });
                     res.end('Hello World HTTP\n');
             }
         });
 
-        httpsServer = https.createServer(httpsOptions, function(req, res) {
+        httpsServer = https.createServer(httpsOptions, function (req, res) {
             res.writeHead(200, {
                 'Content-Type': 'text/plain'
             });
             res.end('Hello World HTTPS\n');
         });
 
-        httpServer.listen(HTTP_PORT, function() {
+        httpServer.listen(HTTP_PORT, function () {
             httpsServer.listen(HTTPS_PORT, done);
         });
     });
 
-    afterEach(function(done) {
-        httpServer.close(function() {
+    afterEach(function (done) {
+        httpServer.close(function () {
             httpsServer.close(done);
         });
     });
 
-    it('should fetch HTTP data', function(done) {
+    it('should fetch HTTP data', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT);
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTP\n');
             done();
         });
     });
 
-    it('should fetch HTTPS data', function(done) {
+    it('should fetch HTTPS data', function (done) {
         let req = fetch('https://localhost:' + HTTPS_PORT);
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTPS\n');
             done();
         });
     });
 
-    it('should fetch HTTP data with redirects', function(done) {
+    it('should fetch HTTP data with redirects', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/redirect3');
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTP\n');
             done();
         });
     });
 
-    it('should return error for too many redirects', function(done) {
+    it('should return error for too many redirects', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/redirect6');
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('error', function(err) {
+        req.on('error', function (err) {
             expect(err).to.exist;
             done();
         });
-        req.on('end', function() {});
+        req.on('end', function () {});
     });
 
-    it('should fetch HTTP data with custom redirect limit', function(done) {
+    it('should fetch HTTP data with custom redirect limit', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/redirect3', {
             maxRedirects: 3
         });
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTP\n');
             done();
         });
     });
 
-    it('should return error for custom redirect limit', function(done) {
+    it('should return error for custom redirect limit', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/redirect3', {
             maxRedirects: 2
         });
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('error', function(err) {
+        req.on('error', function (err) {
             expect(err).to.exist;
             done();
         });
-        req.on('end', function() {});
+        req.on('end', function () {});
     });
 
-    it('should return disable redirects', function(done) {
+    it('should return disable redirects', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/redirect1', {
             maxRedirects: 0
         });
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('error', function(err) {
+        req.on('error', function (err) {
             expect(err).to.exist;
             done();
         });
-        req.on('end', function() {});
+        req.on('end', function () {});
     });
 
-    it('should unzip compressed HTTP data', function(done) {
+    it('should unzip compressed HTTP data', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/gzip');
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTP\n');
             done();
         });
     });
 
-    it('should return error for unresolved host', function(done) {
+    it('should return error for unresolved host', function (done) {
         let req = fetch('http://asfhaskhhgbjdsfhgbsdjgk');
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('error', function(err) {
+        req.on('error', function (err) {
             expect(err).to.exist;
             done();
         });
-        req.on('end', function() {});
+        req.on('end', function () {});
     });
 
-    it('should return error for invalid status', function(done) {
+    it('should return error for invalid status', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/invalid');
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('error', function(err) {
+        req.on('error', function (err) {
             expect(err).to.exist;
             done();
         });
-        req.on('end', function() {});
+        req.on('end', function () {});
     });
 
-    it('should allow invalid status', function(done) {
+    it('should allow invalid status', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/invalid', {
             allowErrorResponse: true
         });
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('error', function(err) {
+        req.on('error', function (err) {
             expect(err).to.not.exist;
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(req.statusCode).to.equal(500);
             expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTP\n');
             done();
         });
     });
 
-    it('should return error for invalid url', function(done) {
+    it('should return error for invalid url', function (done) {
         let req = fetch('http://localhost:99999999/');
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('error', function(err) {
+        req.on('error', function (err) {
             expect(err).to.exist;
             done();
         });
-        req.on('end', function() {});
+        req.on('end', function () {});
     });
 
-    it('should return timeout error', function(done) {
+    it('should return timeout error', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/forever', {
             timeout: 1000
         });
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('error', function(err) {
+        req.on('error', function (err) {
             expect(err).to.exist;
             done();
         });
-        req.on('end', function() {});
+        req.on('end', function () {});
     });
 
-    it('should handle basic HTTP auth', function(done) {
+    it('should handle basic HTTP auth', function (done) {
         let req = fetch('http://user:pass@localhost:' + HTTP_PORT + '/auth');
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(Buffer.concat(buf).toString()).to.equal('user:pass');
             done();
         });
     });
 
     if (!/^0\.10\./.test(process.versions.node)) {
         // disabled for node 0.10
-        it('should return error for invalid protocol', function(done) {
+        it('should return error for invalid protocol', function (done) {
             let req = fetch('http://localhost:' + HTTPS_PORT);
             let buf = [];
-            req.on('data', function(chunk) {
+            req.on('data', function (chunk) {
                 buf.push(chunk);
             });
-            req.on('error', function(err) {
+            req.on('error', function (err) {
                 expect(err).to.exist;
                 done();
             });
-            req.on('end', function() {});
+            req.on('end', function () {});
         });
     }
 
-    it('should set cookie value', function(done) {
+    it('should set cookie value', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/cookie', {
             cookie: 'test=pest'
         });
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(Buffer.concat(buf).toString()).to.equal('test=pest');
             done();
         });
     });
 
-    it('should set user agent', function(done) {
+    it('should set user agent', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/ua', {
             userAgent: 'nodemailer-fetch'
         });
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(Buffer.concat(buf).toString()).to.equal('nodemailer-fetch');
             done();
         });
     });
 
-    it('should post data', function(done) {
+    it('should post data', function (done) {
         let req = fetch('http://localhost:' + HTTP_PORT + '/post', {
             method: 'post',
             body: {
                 hello: 'world 😭',
                 another: 'value'
             }
         });
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(Buffer.concat(buf).toString()).to.equal('hello=world%20%F0%9F%98%AD&another=value');
             done();
         });
     });
 
-    it('should post stream data', function(done) {
+    it('should post stream data', function (done) {
         let body = new PassThrough();
         let data = Buffer.from('hello=world%20%F0%9F%98%AD&another=value');
 
         let req = fetch('http://localhost:' + HTTP_PORT + '/post', {
             method: 'post',
             body
         });
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('end', function() {
+        req.on('end', function () {
             expect(Buffer.concat(buf).toString()).to.equal(data.toString());
             done();
         });
 
         let pos = 0;
-        let writeNext = function() {
+        let writeNext = function () {
             if (pos >= data.length) {
                 return body.end();
             }
             let char = data.slice(pos++, pos);
             body.write(char);
@@ -484,22 +484,22 @@ describe('Fetch Tests', function() {
         };
 
         setImmediate(writeNext);
     });
 
-    it('should return error for invalid cert', function(done) {
+    it('should return error for invalid cert', function (done) {
         let req = fetch('https://localhost:' + HTTPS_PORT, {
             tls: {
                 rejectUnauthorized: true
             }
         });
         let buf = [];
-        req.on('data', function(chunk) {
+        req.on('data', function (chunk) {
             buf.push(chunk);
         });
-        req.on('error', function(err) {
+        req.on('error', function (err) {
             expect(err).to.exist;
             done();
         });
-        req.on('end', function() {});
+        req.on('end', function () {});
     });
 });
diff --git a/test/json-transport/json-transport-test.js b/test/json-transport/json-transport-test.js
index d8f5823..7cd352b 100644
--- a/test/json-transport/json-transport-test.js
+++ b/test/json-transport/json-transport-test.js
@@ -8,12 +8,12 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
 const nodemailer = require('../../lib/nodemailer');
 const chai = require('chai');
 const expect = chai.expect;
 chai.config.includeStack = true;
 
-describe('JSON Transport Tests', function() {
-    it('should return an JSON string', function(done) {
+describe('JSON Transport Tests', function () {
+    it('should return an JSON string', function (done) {
         let transport = nodemailer.createTransport({
             jsonTransport: true
         });
 
         let messageObject = {
@@ -86,11 +86,11 @@ describe('JSON Transport Tests', function() {
             });
             done();
         });
     });
 
-    it('should return an JSON string for calendar event', function(done) {
+    it('should return an JSON string for calendar event', function (done) {
         let transport = nodemailer.createTransport({
             jsonTransport: true
         });
 
         let messageObject = {
diff --git a/test/qp/qp-test.js b/test/qp/qp-test.js
index 8ec61d0..d5951ab 100644
--- a/test/qp/qp-test.js
+++ b/test/qp/qp-test.js
@@ -10,11 +10,11 @@ const expect = chai.expect;
 const crypto = require('crypto');
 const fs = require('fs');
 
 chai.config.includeStack = true;
 
-describe('Quoted-Printable Tests', function() {
+describe('Quoted-Printable Tests', function () {
     let encodeFixtures = [
         ['abcd= ÕÄÖÜ', 'abcd=3D =C3=95=C3=84=C3=96=C3=9C'],
         ['foo bar  ', 'foo bar =20'],
         ['foo bar\t\t', 'foo bar\t=09'],
         ['foo \r\nbar', 'foo=20\r\nbar']
@@ -30,62 +30,62 @@ describe('Quoted-Printable Tests', function() {
     let streamFixture = [
         '123456789012345678  90\r\nõäöüõäöüõäöüõäöüõäöüõäöüõäöüõäöü another line === ',
         '12345678=\r\n90123456=\r\n78=20=20=\r\n90\r\n=C3=B5=\r\n=C3=A4=\r\n=C3=B6=\r\n=C3=BC=\r\n=C3=B5=\r\n=C3=A4=\r\n=C3=B6=\r\n=C3=BC=\r\n=C3=B5=\r\n=C3=A4=\r\n=C3=B6=\r\n=C3=BC=\r\n=C3=B5=\r\n=C3=A4=\r\n=C3=B6=\r\n=C3=BC=\r\n=C3=B5=\r\n=C3=A4=\r\n=C3=B6=\r\n=C3=BC=\r\n=C3=B5=\r\n=C3=A4=\r\n=C3=B6=\r\n=C3=BC=\r\n=C3=B5=\r\n=C3=A4=\r\n=C3=B6=\r\n=C3=BC=\r\n=C3=B5=\r\n=C3=A4=\r\n=C3=B6=\r\n=C3=BC=\r\n=20anoth=\r\ner=20lin=\r\ne=20=3D=\r\n=3D=3D=20'
     ];
 
-    describe('#encode', function() {
-        it('shoud encode UTF-8 string to QP', function() {
-            encodeFixtures.forEach(function(test) {
+    describe('#encode', function () {
+        it('shoud encode UTF-8 string to QP', function () {
+            encodeFixtures.forEach(function (test) {
                 expect(qp.encode(test[0])).to.equal(test[1]);
             });
         });
 
-        it('shoud encode Buffer to QP', function() {
+        it('shoud encode Buffer to QP', function () {
             expect(qp.encode(Buffer.from([0x00, 0x01, 0x02, 0x20, 0x03]))).to.equal('=00=01=02 =03');
         });
     });
 
-    describe('#wrap', function() {
-        it('should wrap long QP encoded lines', function() {
-            wrapFixtures.forEach(function(test) {
+    describe('#wrap', function () {
+        it('should wrap long QP encoded lines', function () {
+            wrapFixtures.forEach(function (test) {
                 expect(qp.wrap(test[0], 20)).to.equal(test[1]);
             });
         });
 
-        it('should wrap line ending with <CR>', function() {
+        it('should wrap line ending with <CR>', function () {
             expect(qp.wrap('alfa palfa kalfa ralfa\r', 10)).to.equal('alfa palf=\r\na kalfa =\r\nralfa\r');
         });
     });
 
-    describe('QP Streams', function() {
-        it('should transform incoming bytes to QP', function(done) {
+    describe('QP Streams', function () {
+        it('should transform incoming bytes to QP', function (done) {
             let encoder = new qp.Encoder({
                 lineLength: 9
             });
 
             let bytes = Buffer.from(streamFixture[0]),
                 i = 0,
                 buf = [],
                 buflen = 0;
 
-            encoder.on('data', function(chunk) {
+            encoder.on('data', function (chunk) {
                 buf.push(chunk);
                 buflen += chunk.length;
             });
 
-            encoder.on('end', function(chunk) {
+            encoder.on('end', function (chunk) {
                 if (chunk) {
                     buf.push(chunk);
                     buflen += chunk.length;
                 }
                 buf = Buffer.concat(buf, buflen);
 
                 expect(buf.toString()).to.equal(streamFixture[1]);
                 done();
             });
 
-            let sendNextByte = function() {
+            let sendNextByte = function () {
                 if (i >= bytes.length) {
                     return encoder.end();
                 }
 
                 let ord = bytes[i++];
@@ -94,33 +94,33 @@ describe('Quoted-Printable Tests', function() {
             };
 
             sendNextByte();
         });
 
-        it('should transform incoming bytes to QP and back', function(done) {
+        it('should transform incoming bytes to QP and back', function (done) {
             let decoder = new libqp.Decoder();
             let encoder = new qp.Encoder();
             let file = fs.createReadStream(__dirname + '/fixtures/alice.txt');
 
             let fhash = crypto.createHash('md5');
             let dhash = crypto.createHash('md5');
 
             file.pipe(encoder).pipe(decoder);
 
-            file.on('data', function(chunk) {
+            file.on('data', function (chunk) {
                 fhash.update(chunk);
             });
 
-            file.on('end', function() {
+            file.on('end', function () {
                 fhash = fhash.digest('hex');
             });
 
-            decoder.on('data', function(chunk) {
+            decoder.on('data', function (chunk) {
                 dhash.update(chunk);
             });
 
-            decoder.on('end', function() {
+            decoder.on('end', function () {
                 dhash = dhash.digest('hex');
                 expect(fhash).to.equal(dhash);
                 done();
             });
         });
diff --git a/test/sendmail/le-unix.test.js b/test/sendmail/le-unix.test.js
index a7fc3dc..4f45696 100644
--- a/test/sendmail/le-unix.test.js
+++ b/test/sendmail/le-unix.test.js
@@ -7,12 +7,12 @@ const LeUnix = require('../../lib/sendmail-transport/le-unix');
 const chai = require('chai');
 const expect = chai.expect;
 
 chai.config.includeStack = true;
 
-describe('Sendmail Unix Newlines', function() {
-    it('should rewrite all linebreaks (byte by byte)', function(done) {
+describe('Sendmail Unix Newlines', function () {
+    it('should rewrite all linebreaks (byte by byte)', function (done) {
         let source = 'tere tere\nteine rida\nkolmas rida\r\nneljas rida\r\nviies rida\n kuues rida';
 
         let chunks = [];
         let out = new LeUnix();
         out.on('data', chunk => chunks.push(chunk));
@@ -32,11 +32,11 @@ describe('Sendmail Unix Newlines', function() {
         };
 
         setImmediate(writeNextByte);
     });
 
-    it('should rewrite all linebreaks (all at once)', function(done) {
+    it('should rewrite all linebreaks (all at once)', function (done) {
         let source = 'tere tere\nteine rida\nkolmas rida\r\nneljas rida\r\nviies rida\n kuues rida';
 
         let chunks = [];
         let out = new LeUnix();
         out.on('data', chunk => chunks.push(chunk));
diff --git a/test/sendmail/le-windows-test.js b/test/sendmail/le-windows-test.js
index 93ce0c0..c928eda 100644
--- a/test/sendmail/le-windows-test.js
+++ b/test/sendmail/le-windows-test.js
@@ -7,12 +7,12 @@ const LeWindows = require('../../lib/sendmail-transport/le-windows');
 const chai = require('chai');
 const expect = chai.expect;
 
 chai.config.includeStack = true;
 
-describe('Sendmail Windows Newlines', function() {
-    it('should rewrite all linebreaks (byte by byte)', function(done) {
+describe('Sendmail Windows Newlines', function () {
+    it('should rewrite all linebreaks (byte by byte)', function (done) {
         let source = 'tere tere\nteine rida\nkolmas rida\r\nneljas rida\r\nviies rida\n kuues rida';
 
         let chunks = [];
         let out = new LeWindows();
         out.on('data', chunk => chunks.push(chunk));
@@ -32,11 +32,11 @@ describe('Sendmail Windows Newlines', function() {
         };
 
         setImmediate(writeNextByte);
     });
 
-    it('should rewrite all linebreaks (all at once)', function(done) {
+    it('should rewrite all linebreaks (all at once)', function (done) {
         let source = 'tere tere\nteine rida\nkolmas rida\r\nneljas rida\r\nviies rida\n kuues rida';
 
         let chunks = [];
         let out = new LeWindows();
         out.on('data', chunk => chunks.push(chunk));
diff --git a/test/sendmail/sendmail-test.js b/test/sendmail/sendmail-test.js
index 6d412d1..35ac79f 100644
--- a/test/sendmail/sendmail-test.js
+++ b/test/sendmail/sendmail-test.js
@@ -37,30 +37,30 @@ class MockBuilder {
     getHeader() {
         return 'teretere';
     }
 }
 
-describe('Sendmail Transport Tests', function() {
-    it('Should expose version number', function() {
+describe('Sendmail Transport Tests', function () {
+    it('Should expose version number', function () {
         let client = new SendmailTransport();
         expect(client.name).to.exist;
         expect(client.version).to.exist;
     });
 
-    it('Should send message', function(done) {
+    it('Should send message', function (done) {
         let client = new SendmailTransport();
 
         let stubbedSpawn = new EventEmitter();
         stubbedSpawn.stdin = new PassThrough();
         stubbedSpawn.stdout = new PassThrough();
 
         let output = '';
-        stubbedSpawn.stdin.on('data', function(chunk) {
+        stubbedSpawn.stdin.on('data', function (chunk) {
             output += chunk.toString();
         });
 
-        stubbedSpawn.stdin.on('end', function() {
+        stubbedSpawn.stdin.on('end', function () {
             stubbedSpawn.emit('close', 0);
             stubbedSpawn.emit('exit', 0);
         });
 
         sinon.stub(client, '_spawn').returns(stubbedSpawn);
@@ -74,30 +74,70 @@ describe('Sendmail Transport Tests', function() {
                         to: 'test@valid.recipient'
                     },
                     'message\r\nline 2'
                 )
             },
-            function(err, data) {
+            function (err, data) {
                 expect(err).to.not.exist;
                 expect(data.messageId).to.equal('<test>');
                 expect(output).to.equal('message\nline 2');
                 client._spawn.restore();
                 done();
             }
         );
     });
 
-    it('Should return an error', function(done) {
+    it('Should reject message', function (done) {
+        let client = new SendmailTransport();
+
+        let stubbedSpawn = new EventEmitter();
+        stubbedSpawn.stdin = new PassThrough();
+        stubbedSpawn.stdout = new PassThrough();
+
+        let output = '';
+        stubbedSpawn.stdin.on('data', function (chunk) {
+            output += chunk.toString();
+        });
+
+        stubbedSpawn.stdin.on('end', function () {
+            stubbedSpawn.emit('close', 0);
+            stubbedSpawn.emit('exit', 0);
+        });
+
+        sinon.stub(client, '_spawn').returns(stubbedSpawn);
+
+        client.send(
+            {
+                data: {},
+                message: new MockBuilder(
+                    {
+                        from: 'test@valid.sender',
+                        to: '-d0.1a@example.com'
+                    },
+                    'message\r\nline 2'
+                )
+            },
+            function (err, data) {
+                expect(err).to.exist;
+                expect(data).to.not.exist;
+                expect(output).to.equal('');
+                client._spawn.restore();
+                done();
+            }
+        );
+    });
+
+    it('Should return an error', function (done) {
         let client = new SendmailTransport();
 
         let stubbedSpawn = new EventEmitter();
         stubbedSpawn.stdin = new PassThrough();
         stubbedSpawn.stdout = new PassThrough();
 
         stubbedSpawn.stdin.on('data', () => false);
 
-        stubbedSpawn.stdin.on('end', function() {
+        stubbedSpawn.stdin.on('end', function () {
             stubbedSpawn.emit('close', 127);
             stubbedSpawn.emit('exit', 127);
         });
 
         sinon.stub(client, '_spawn').returns(stubbedSpawn);
@@ -111,11 +151,11 @@ describe('Sendmail Transport Tests', function() {
                         to: 'test@valid.recipient'
                     },
                     'message\r\nline 2'
                 )
             },
-            function(err, data) {
+            function (err, data) {
                 expect(err).to.exist;
                 expect(data).to.not.exist;
                 client._spawn.restore();
                 done();
             }
diff --git a/test/ses-transport/ses-transport-test.js b/test/ses-transport/ses-transport-test.js
index 8c7a997..47bd397 100644
--- a/test/ses-transport/ses-transport-test.js
+++ b/test/ses-transport/ses-transport-test.js
@@ -19,14 +19,14 @@ QzAp+zVKWqDqPfX7L93SQLzOGhdd7OECMQDeQyD7WBkjSQNMy/GF7I1qxrscIxNN
 VqGTcbu8Lti285Hjhx/sqhHHHGwU9vB7oM8CMQDKTS3Kw/s/xrot5O+kiZwFgr+w
 cmDrj/7jJHb+ykFNb7GaEkiSYqzUjKkfpweBDYECMFJUyzuuFJAjq3BXmGJlyykQ
 TweUw+zMVdSXjO+FCPcYNi6CP1t1KoESzGKBVoqA/g==
 -----END RSA PRIVATE KEY-----`;
 
-describe('SES Transport Tests', function() {
+describe('SES Transport Tests', function () {
     this.timeout(50 * 1000); // eslint-disable-line no-invalid-this
 
-    it('should return MessageId', function(done) {
+    it('should return MessageId', function (done) {
         let transport = nodemailer.createTransport({
             SES: {
                 config: {
                     region: 'eu-west-1'
                 },
@@ -71,11 +71,11 @@ describe('SES Transport Tests', function() {
             expect(info.response).to.equal('testtest');
             done();
         });
     });
 
-    it('should sign message with DKIM', function(done) {
+    it('should sign message with DKIM', function (done) {
         let transport = nodemailer.createTransport({
             SES: {
                 config: {
                     region: 'eu-west-1'
                 },
@@ -125,11 +125,11 @@ describe('SES Transport Tests', function() {
             expect(info.response).to.equal('testtest');
             done();
         });
     });
 
-    it('should limit parallel connections', function(done) {
+    it('should limit parallel connections', function (done) {
         let transport = nodemailer.createTransport({
             maxConnections: 2,
             SES: {
                 config: {
                     region: 'eu-west-1'
@@ -186,11 +186,11 @@ describe('SES Transport Tests', function() {
                 }
             });
         }
     });
 
-    it('should rate limit messages', function(done) {
+    it('should rate limit messages', function (done) {
         let transport = nodemailer.createTransport({
             sendingRate: 10,
             SES: {
                 config: {
                     region: 'eu-west-1'
@@ -247,11 +247,11 @@ describe('SES Transport Tests', function() {
                 }
             });
         }
     });
 
-    it('should rate limit long messages', function(done) {
+    it('should rate limit long messages', function (done) {
         let transport = nodemailer.createTransport({
             sendingRate: 30,
             SES: {
                 config: {
                     region: 'eu-west-1'
@@ -308,11 +308,11 @@ describe('SES Transport Tests', function() {
                 }
             });
         }
     });
 
-    it('should rate limit messages and connections', function(done) {
+    it('should rate limit messages and connections', function (done) {
         let transport = nodemailer.createTransport({
             sendingRate: 100,
             maxConnections: 1,
             SES: {
                 config: {
@@ -371,11 +371,11 @@ describe('SES Transport Tests', function() {
                 }
             });
         }
     });
 
-    it('detect sending slots on idle events', function(done) {
+    it('detect sending slots on idle events', function (done) {
         let transport = nodemailer.createTransport({
             sendingRate: 100,
             maxConnections: 1,
             SES: {
                 config: {
diff --git a/test/shared/shared-test.js b/test/shared/shared-test.js
index 6ea4ef7..e328ba6 100644
--- a/test/shared/shared-test.js
+++ b/test/shared/shared-test.js
@@ -11,13 +11,13 @@ const http = require('http');
 const fs = require('fs');
 const zlib = require('zlib');
 
 chai.config.includeStack = true;
 
-describe('Shared Funcs Tests', function() {
-    describe('Logger tests', function() {
-        it('Should create a logger', function() {
+describe('Shared Funcs Tests', function () {
+    describe('Logger tests', function () {
+        it('Should create a logger', function () {
             expect(
                 typeof shared.getLogger({
                     logger: false
                 })
             ).to.equal('object');
@@ -28,12 +28,12 @@ describe('Shared Funcs Tests', function() {
             ).to.equal('object');
             expect(typeof shared.getLogger()).to.equal('object');
         });
     });
 
-    describe('Connection url parser tests', function() {
-        it('Should parse connection url', function() {
+    describe('Connection url parser tests', function () {
+        it('Should parse connection url', function () {
             let url = 'smtps://user:pass@localhost:123?tls.rejectUnauthorized=false&name=horizon';
             expect(shared.parseConnectionUrl(url)).to.deep.equal({
                 secure: true,
                 port: 123,
                 host: 'localhost',
@@ -46,11 +46,11 @@ describe('Shared Funcs Tests', function() {
                 },
                 name: 'horizon'
             });
         });
 
-        it('should not choke on special symbols in auth', function() {
+        it('should not choke on special symbols in auth', function () {
             let url = 'smtps://user%40gmail.com:%3Apasswith%25Char@smtp.gmail.com';
             expect(shared.parseConnectionUrl(url)).to.deep.equal({
                 secure: true,
                 host: 'smtp.gmail.com',
                 auth: {
@@ -59,16 +59,16 @@ describe('Shared Funcs Tests', function() {
                 }
             });
         });
     });
 
-    describe('Resolver tests', function() {
+    describe('Resolver tests', function () {
         let port = 10337;
         let server;
 
-        beforeEach(function(done) {
-            server = http.createServer(function(req, res) {
+        beforeEach(function (done) {
+            server = http.createServer(function (req, res) {
                 if (/redirect/.test(req.url)) {
                     res.writeHead(302, {
                         Location: 'http://localhost:' + port + '/message.html'
                     });
                     res.end('Go to http://localhost:' + port + '/message.html');
@@ -90,107 +90,107 @@ describe('Shared Funcs Tests', function() {
             });
 
             server.listen(port, done);
         });
 
-        afterEach(function(done) {
+        afterEach(function (done) {
             server.close(done);
         });
 
-        it('should set text from html string', function(done) {
+        it('should set text from html string', function (done) {
             let mail = {
                 data: {
                     html: '<p>Tere, tere</p><p>vana kere!</p>\n'
                 }
             };
-            shared.resolveContent(mail.data, 'html', function(err, value) {
+            shared.resolveContent(mail.data, 'html', function (err, value) {
                 expect(err).to.not.exist;
                 expect(value).to.equal('<p>Tere, tere</p><p>vana kere!</p>\n');
                 done();
             });
         });
 
-        it('should set text from html buffer', function(done) {
+        it('should set text from html buffer', function (done) {
             let mail = {
                 data: {
                     html: Buffer.from('<p>Tere, tere</p><p>vana kere!</p>\n')
                 }
             };
-            shared.resolveContent(mail.data, 'html', function(err, value) {
+            shared.resolveContent(mail.data, 'html', function (err, value) {
                 expect(err).to.not.exist;
                 expect(value).to.deep.equal(mail.data.html);
                 done();
             });
         });
 
-        it('should set text from a html file', function(done) {
+        it('should set text from a html file', function (done) {
             let mail = {
                 data: {
                     html: {
                         path: __dirname + '/fixtures/message.html'
                     }
                 }
             };
-            shared.resolveContent(mail.data, 'html', function(err, value) {
+            shared.resolveContent(mail.data, 'html', function (err, value) {
                 expect(err).to.not.exist;
                 expect(value).to.deep.equal(Buffer.from('<p>Tere, tere</p><p>vana kere!</p>\n'));
                 done();
             });
         });
 
-        it('should set text from an html url', function(done) {
+        it('should set text from an html url', function (done) {
             let mail = {
                 data: {
                     html: {
                         path: 'http://localhost:' + port + '/message.html'
                     }
                 }
             };
-            shared.resolveContent(mail.data, 'html', function(err, value) {
+            shared.resolveContent(mail.data, 'html', function (err, value) {
                 expect(err).to.not.exist;
                 expect(value).to.deep.equal(Buffer.from('<p>Tere, tere</p><p>vana kere!</p>\n'));
                 done();
             });
         });
 
-        it('should set text from redirecting url', function(done) {
+        it('should set text from redirecting url', function (done) {
             let mail = {
                 data: {
                     html: {
                         path: 'http://localhost:' + port + '/redirect.html'
                     }
                 }
             };
-            shared.resolveContent(mail.data, 'html', function(err, value) {
+            shared.resolveContent(mail.data, 'html', function (err, value) {
                 expect(err).to.not.exist;
                 expect(value).to.deep.equal(Buffer.from('<p>Tere, tere</p><p>vana kere!</p>\n'));
                 done();
             });
         });
 
-        it('should set text from gzipped url', function(done) {
+        it('should set text from gzipped url', function (done) {
             let mail = {
                 data: {
                     html: {
                         path: 'http://localhost:' + port + '/compressed.html'
                     }
                 }
             };
-            shared.resolveContent(mail.data, 'html', function(err, value) {
+            shared.resolveContent(mail.data, 'html', function (err, value) {
                 expect(err).to.not.exist;
                 expect(value).to.deep.equal(Buffer.from('<p>Tere, tere</p><p>vana kere!</p>\n'));
                 done();
             });
         });
 
-        it('should set text from a html stream', function(done) {
+        it('should set text from a html stream', function (done) {
             let mail = {
                 data: {
                     html: fs.createReadStream(__dirname + '/fixtures/message.html')
                 }
             };
-            shared.resolveContent(mail.data, 'html', function(err, value) {
+            shared.resolveContent(mail.data, 'html', function (err, value) {
                 expect(err).to.not.exist;
                 expect(mail).to.deep.equal({
                     data: {
                         html: Buffer.from('<p>Tere, tere</p><p>vana kere!</p>\n')
                     }
@@ -198,52 +198,52 @@ describe('Shared Funcs Tests', function() {
                 expect(value).to.deep.equal(Buffer.from('<p>Tere, tere</p><p>vana kere!</p>\n'));
                 done();
             });
         });
 
-        it('should return an error', function(done) {
+        it('should return an error', function (done) {
             let mail = {
                 data: {
                     html: {
                         path: 'http://localhost:' + (port + 1000) + '/message.html'
                     }
                 }
             };
-            shared.resolveContent(mail.data, 'html', function(err) {
+            shared.resolveContent(mail.data, 'html', function (err) {
                 expect(err).to.exist;
                 done();
             });
         });
 
-        it('should return encoded string as buffer', function(done) {
+        it('should return encoded string as buffer', function (done) {
             let str = '<p>Tere, tere</p><p>vana kere!</p>\n';
             let mail = {
                 data: {
                     html: {
                         encoding: 'base64',
                         content: Buffer.from(str).toString('base64')
                     }
                 }
             };
-            shared.resolveContent(mail.data, 'html', function(err, value) {
+            shared.resolveContent(mail.data, 'html', function (err, value) {
                 expect(err).to.not.exist;
                 expect(value).to.deep.equal(Buffer.from(str));
                 done();
             });
         });
 
-        describe('data uri tests', function() {
-            it('should resolve with mime type and base64', function(done) {
+        describe('data uri tests', function () {
+            it('should resolve with mime type and base64', function (done) {
                 let mail = {
                     data: {
                         attachment: {
                             path:
                                 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
                         }
                     }
                 };
-                shared.resolveContent(mail.data, 'attachment', function(err, value) {
+                shared.resolveContent(mail.data, 'attachment', function (err, value) {
                     expect(err).to.not.exist;
                     expect(value).to.deep.equal(
                         Buffer.from(
                             'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==',
                             'base64'
@@ -251,50 +251,50 @@ describe('Shared Funcs Tests', function() {
                     );
                     done();
                 });
             });
 
-            it('should resolve with mime type and plaintext', function(done) {
+            it('should resolve with mime type and plaintext', function (done) {
                 let mail = {
                     data: {
                         attachment: {
                             path: 'data:image/png,tere%20tere'
                         }
                     }
                 };
-                shared.resolveContent(mail.data, 'attachment', function(err, value) {
+                shared.resolveContent(mail.data, 'attachment', function (err, value) {
                     expect(err).to.not.exist;
                     expect(value).to.deep.equal(Buffer.from('tere tere'));
                     done();
                 });
             });
 
-            it('should resolve with plaintext', function(done) {
+            it('should resolve with plaintext', function (done) {
                 let mail = {
                     data: {
                         attachment: {
                             path: 'data:,tere%20tere'
                         }
                     }
                 };
-                shared.resolveContent(mail.data, 'attachment', function(err, value) {
+                shared.resolveContent(mail.data, 'attachment', function (err, value) {
                     expect(err).to.not.exist;
                     expect(value).to.deep.equal(Buffer.from('tere tere'));
                     done();
                 });
             });
 
-            it('should resolve with mime type, charset and base64', function(done) {
+            it('should resolve with mime type, charset and base64', function (done) {
                 let mail = {
                     data: {
                         attachment: {
                             path:
                                 'data:image/png;charset=iso-8859-1;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
                         }
                     }
                 };
-                shared.resolveContent(mail.data, 'attachment', function(err, value) {
+                shared.resolveContent(mail.data, 'attachment', function (err, value) {
                     expect(err).to.not.exist;
                     expect(value).to.deep.equal(
                         Buffer.from(
                             'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==',
                             'base64'
@@ -304,12 +304,12 @@ describe('Shared Funcs Tests', function() {
                 });
             });
         });
     });
 
-    describe('#assign tests', function() {
-        it('should assign multiple objects to target', function() {
+    describe('#assign tests', function () {
+        it('should assign multiple objects to target', function () {
             let target = {
                 a: 1,
                 b: 2,
                 c: 3
             };
@@ -334,27 +334,27 @@ describe('Shared Funcs Tests', function() {
                 qq: 98
             });
         });
     });
 
-    describe('#encodeXText tests', function() {
-        it('should not encode atom', function() {
+    describe('#encodeXText tests', function () {
+        it('should not encode atom', function () {
             expect(shared.encodeXText('teretere')).to.equal('teretere');
         });
 
-        it('should not encode email', function() {
+        it('should not encode email', function () {
             expect(shared.encodeXText('andris.reinman@gmail.com')).to.equal('andris.reinman@gmail.com');
         });
 
-        it('should encode space', function() {
+        it('should encode space', function () {
             expect(shared.encodeXText('tere tere')).to.equal('tere+20tere');
         });
 
-        it('should encode unicode', function() {
+        it('should encode unicode', function () {
             expect(shared.encodeXText('tere tõre')).to.equal('tere+20t+C3+B5re');
         });
 
-        it('should encode low codes', function() {
+        it('should encode low codes', function () {
             expect(shared.encodeXText('tere t\tre')).to.equal('tere+20t+09re');
         });
     });
 });
diff --git a/test/smtp-connection/http-proxy-client-test.js b/test/smtp-connection/http-proxy-client-test.js
index 23c161b..180cde2 100644
--- a/test/smtp-connection/http-proxy-client-test.js
+++ b/test/smtp-connection/http-proxy-client-test.js
@@ -13,12 +13,12 @@ const expect = chai.expect;
 chai.config.includeStack = true;
 
 const PROXY_PORT = 3128;
 const TARGET_PORT = 3129;
 
-describe('HTTP Proxy Client Tests', function() {
-    it('should connect to a socket through proxy', function(done) {
+describe('HTTP Proxy Client Tests', function () {
+    it('should connect to a socket through proxy', function (done) {
         let smtpServer = new SMTPServer({
             logger: false
         });
 
         smtpServer.listen(TARGET_PORT, () => {
@@ -36,11 +36,11 @@ describe('HTTP Proxy Client Tests', function() {
                     });
                 });
             });
         });
     });
-    it('should connect to a socket through proxy with auth', function(done) {
+    it('should connect to a socket through proxy with auth', function (done) {
         let smtpServer = new SMTPServer({
             logger: false
         });
 
         smtpServer.listen(TARGET_PORT, () => {
@@ -62,11 +62,11 @@ describe('HTTP Proxy Client Tests', function() {
                 });
             });
         });
     });
 
-    it('should should fail auth', function(done) {
+    it('should should fail auth', function (done) {
         let smtpServer = new SMTPServer({
             logger: false
         });
 
         smtpServer.listen(TARGET_PORT, () => {
diff --git a/test/smtp-connection/smtp-connection-test.js b/test/smtp-connection/smtp-connection-test.js
index ace9dd1..3ca086f 100644
--- a/test/smtp-connection/smtp-connection-test.js
+++ b/test/smtp-connection/smtp-connection-test.js
@@ -22,459 +22,454 @@ chai.config.includeStack = true;
 let PORT_NUMBER = 8397;
 let PROXY_PORT_NUMBER = 9999;
 let LMTP_PORT_NUMBER = 8396;
 let XOAUTH_PORT = 8497;
 
-describe('SMTP-Connection Tests', function() {
-    describe('Version test', function() {
-        it('Should expose version number', function() {
+describe('SMTP-Connection Tests', function () {
+    describe('Version test', function () {
+        it('Should expose version number', function () {
             let client = new SMTPConnection();
             expect(client.version).to.equal(packageData.version);
         });
     });
 
-    describe('Connection tests', function() {
+    describe('Connection tests', function () {
         let server, insecureServer, invalidServer, secureServer, httpProxy;
 
-        beforeEach(function(done) {
+        beforeEach(function (done) {
             server = new SMTPServer({
-                onAuth: function(auth, session, callback) {
+                onAuth: function (auth, session, callback) {
                     if (auth.username !== 'testuser' || auth.password !== 'testpass') {
                         return callback(new Error('Invalid username or password'));
                     }
                     callback(null, {
                         user: 123
                     });
                 },
-                onData: function(stream, session, callback) {
-                    stream.on('data', function() {});
+                onData: function (stream, session, callback) {
+                    stream.on('data', function () {});
                     stream.on('end', callback);
                 }
             });
 
             insecureServer = new SMTPServer({
                 disabledCommands: ['STARTTLS', 'AUTH'],
-                onData: function(stream, session, callback) {
+                onData: function (stream, session, callback) {
                     let err = false;
-                    stream.on('data', function(chunk) {
+                    stream.on('data', function (chunk) {
                         if (err || session.use8BitMime) {
                             return;
                         }
                         for (let i = 0, len = chunk.length; i < len; i++) {
                             if (chunk[i] >= 0x80) {
                                 err = new Error('8 bit content not allowed');
                             }
                         }
                     });
-                    stream.on('end', function() {
+                    stream.on('end', function () {
                         callback(err, false);
                     });
                 },
                 logger: false
             });
 
-            invalidServer = net.createServer(function() {});
+            invalidServer = net.createServer(function () {});
 
             secureServer = new SMTPServer({
                 secure: true,
-                onAuth: function(auth, session, callback) {
+                onAuth: function (auth, session, callback) {
                     if (auth.username !== 'testuser' || auth.password !== 'testpass') {
                         return callback(new Error('Invalid username or password'));
                     }
                     callback(null, {
                         user: 123
                     });
                 },
-                onData: function(stream, session, callback) {
-                    stream.on('data', function() {});
+                onData: function (stream, session, callback) {
+                    stream.on('data', function () {});
                     stream.on('end', callback);
                 },
                 logger: false
             });
 
             httpProxy = new HttpConnectProxy();
 
-            server.listen(PORT_NUMBER, function() {
-                invalidServer.listen(PORT_NUMBER + 1, function() {
-                    secureServer.listen(PORT_NUMBER + 2, function() {
-                        insecureServer.listen(PORT_NUMBER + 3, function() {
+            server.listen(PORT_NUMBER, function () {
+                invalidServer.listen(PORT_NUMBER + 1, function () {
+                    secureServer.listen(PORT_NUMBER + 2, function () {
+                        insecureServer.listen(PORT_NUMBER + 3, function () {
                             httpProxy.listen(PROXY_PORT_NUMBER, done);
                         });
                     });
                 });
             });
         });
 
-        afterEach(function(done) {
-            server.close(function() {
-                invalidServer.close(function() {
-                    secureServer.close(function() {
-                        insecureServer.close(function() {
+        afterEach(function (done) {
+            server.close(function () {
+                invalidServer.close(function () {
+                    secureServer.close(function () {
+                        insecureServer.close(function () {
                             httpProxy.close(done);
                         });
                     });
                 });
             });
         });
 
-        it('should connect to unsecure server', function(done) {
+        it('should connect to unsecure server', function (done) {
             let client = new SMTPConnection({
                 port: PORT_NUMBER + 3,
                 ignoreTLS: true,
                 logger: false
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 expect(client.secure).to.be.false;
                 client.close();
             });
 
-            client.on('error', function(err) {
+            client.on('error', function (err) {
                 expect(err).to.not.exist;
             });
 
             client.on('end', done);
         });
 
-        it('should connect to a server and upgrade with STARTTLS', function(done) {
+        it('should connect to a server and upgrade with STARTTLS', function (done) {
             let client = new SMTPConnection({
                 port: PORT_NUMBER,
                 logger: false
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 expect(client.secure).to.be.true;
                 client.close();
             });
 
-            client.on('error', function(err) {
+            client.on('error', function (err) {
                 expect(err).to.not.exist;
             });
 
             client.on('end', done);
         });
 
-        it('should connect to a server and upgrade with forced STARTTLS', function(done) {
+        it('should connect to a server and upgrade with forced STARTTLS', function (done) {
             let client = new SMTPConnection({
                 port: PORT_NUMBER,
                 requireTLS: true,
                 transactionLog: true,
                 logger: false
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 expect(client.secure).to.be.true;
                 client.close();
             });
 
-            client.on('error', function(err) {
+            client.on('error', function (err) {
                 expect(err).to.not.exist;
             });
 
             client.on('end', done);
         });
 
-        it('should connect to a server and try to upgrade STARTTLS', function(done) {
+        it('should connect to a server and try to upgrade STARTTLS', function (done) {
             let client = new SMTPConnection({
                 port: PORT_NUMBER + 3,
                 logger: false,
                 requireTLS: true,
                 opportunisticTLS: true
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 expect(client.secure).to.be.false;
                 client.close();
             });
 
-            client.on('error', function(err) {
+            client.on('error', function (err) {
                 expect(err).to.not.exist;
             });
 
             client.on('end', done);
         });
 
-        it('should try upgrade with STARTTLS where not advertised', function(done) {
+        it('should try upgrade with STARTTLS where not advertised', function (done) {
             let client = new SMTPConnection({
                 port: PORT_NUMBER + 3,
                 requireTLS: true,
                 logger: false
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 // should not run
                 expect(false).to.be.true;
                 client.close();
             });
 
-            client.once('error', function(err) {
+            client.once('error', function (err) {
                 expect(err).to.exist;
             });
 
             client.on('end', done);
         });
 
-        it('should close connection after STARTTLS', function(done) {
+        it('should close connection after STARTTLS', function (done) {
             let client = new SMTPConnection({
                 port: PORT_NUMBER,
                 logger: false
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 expect(client.secure).to.be.true;
-                server.connections.forEach(function(conn) {
+                server.connections.forEach(function (conn) {
                     conn.close();
                 });
             });
 
-            client.on('error', function(err) {
+            client.on('error', function (err) {
                 expect(err.message).to.equal('Connection closed unexpectedly');
             });
 
             client.on('end', done);
         });
 
-        it('should connect to a secure server', function(done) {
+        it('should connect to a secure server', function (done) {
             let client = new SMTPConnection({
                 port: PORT_NUMBER + 2,
                 secure: true,
                 logger: false
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 expect(client.secure).to.be.true;
                 client.close();
             });
 
-            client.on('error', function(err) {
+            client.on('error', function (err) {
                 expect(err).to.not.exist;
             });
 
             client.on('end', done);
         });
 
-        it('should emit error for invalid port', function(done) {
+        it('should emit error for invalid port', function (done) {
             let client = new SMTPConnection({
                 port: PORT_NUMBER + 10,
                 logger: false
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 // should not run
                 expect(false).to.be.true;
                 client.close();
             });
 
-            client.once('error', function(err) {
+            client.once('error', function (err) {
                 expect(err).to.exist;
             });
 
             client.on('end', done);
         });
 
-        it('should emit error for too large port', function(done) {
+        it('should emit error for too large port', function (done) {
             let client = new SMTPConnection({
                 port: 999999999,
                 logger: false
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 // should not run
                 expect(false).to.be.true;
                 client.close();
             });
 
-            client.once('error', function(err) {
+            client.once('error', function (err) {
                 expect(err).to.exist;
             });
 
             client.on('end', done);
         });
 
-        it('should emit inactivity timeout error', function(done) {
+        it('should emit inactivity timeout error', function (done) {
             let client = new SMTPConnection({
                 port: PORT_NUMBER,
                 socketTimeout: 100,
                 logger: false
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 // do nothing
             });
 
-            client.once('error', function(err) {
+            client.once('error', function (err) {
                 expect(err).to.exist;
                 expect(err.code).to.equal('ETIMEDOUT');
             });
 
             client.on('end', done);
         });
 
-        it('should connect through proxy', function(done) {
-            let runTest = function(socket) {
+        it('should connect through proxy', function (done) {
+            let runTest = function (socket) {
                 let client = new SMTPConnection({
                     logger: false,
                     port: PORT_NUMBER,
                     connection: socket
                 });
 
-                client.connect(function() {
+                client.connect(function () {
                     expect(client.secure).to.be.true;
                     client.login(
                         {
                             user: 'testuser',
                             credentials: {
                                 user: 'testuser',
                                 pass: 'testpass'
                             }
                         },
-                        function(err) {
+                        function (err) {
                             expect(err).to.not.exist;
                             expect(client.authenticated).to.be.true;
                             client.close();
                         }
                     );
                 });
 
-                client.on('error', function(err) {
+                client.on('error', function (err) {
                     expect(err).to.not.exist;
                 });
 
                 client.on('end', done);
             };
 
-            proxyConnect(PROXY_PORT_NUMBER, '127.0.0.1', PORT_NUMBER, '127.0.0.1', function(err, socket) {
+            proxyConnect(PROXY_PORT_NUMBER, '127.0.0.1', PORT_NUMBER, '127.0.0.1', function (err, socket) {
                 expect(err).to.not.exist;
                 runTest(socket);
             });
         });
 
-        it('should connect through proxy to secure server', function(done) {
-            let runTest = function(socket) {
+        it('should connect through proxy to secure server', function (done) {
+            let runTest = function (socket) {
                 let client = new SMTPConnection({
                     logger: false,
                     port: PORT_NUMBER + 2,
                     secure: true,
                     connection: socket
                 });
 
-                client.connect(function() {
+                client.connect(function () {
                     expect(client.secure).to.be.true;
                     client.login(
                         {
                             user: 'testuser',
                             credentials: {
                                 user: 'testuser',
                                 pass: 'testpass'
                             }
                         },
-                        function(err) {
+                        function (err) {
                             expect(err).to.not.exist;
                             expect(client.authenticated).to.be.true;
                             client.close();
                         }
                     );
                 });
 
-                client.on('error', function(err) {
+                client.on('error', function (err) {
                     expect(err).to.not.exist;
                 });
 
                 client.on('end', done);
             };
 
-            proxyConnect(PROXY_PORT_NUMBER, '127.0.0.1', PORT_NUMBER + 2, '127.0.0.1', function(err, socket) {
+            proxyConnect(PROXY_PORT_NUMBER, '127.0.0.1', PORT_NUMBER + 2, '127.0.0.1', function (err, socket) {
                 expect(err).to.not.exist;
                 runTest(socket);
             });
         });
 
-        it('should send to unsecure server', function(done) {
+        it('should send to unsecure server', function (done) {
             let client = new SMTPConnection({
                 port: PORT_NUMBER + 3,
                 ignoreTLS: true,
                 logger: false
             });
 
-            client.on('error', function(err) {
+            client.on('error', function (err) {
                 expect(err).to.not.exist;
             });
 
-            client.connect(function() {
+            client.connect(function () {
                 expect(client.secure).to.be.false;
 
                 let chunks = [],
                     fname = __dirname + '/../../LICENSE',
                     message = fs.readFileSync(fname, 'utf-8');
 
-                server.on('data', function(connection, chunk) {
+                server.on('data', function (connection, chunk) {
                     chunks.push(chunk);
                 });
 
                 server.removeAllListeners('dataReady');
-                server.on('dataReady', function(connection, callback) {
+                server.on('dataReady', function (connection, callback) {
                     let body = Buffer.concat(chunks);
-                    expect(body.toString()).to.equal(
-                        message
-                            .toString()
-                            .trim()
-                            .replace(/\n/g, '\r\n')
-                    );
+                    expect(body.toString()).to.equal(message.toString().trim().replace(/\n/g, '\r\n'));
                     callback(null, 'ABC1');
                 });
 
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: 'test@valid.recipient'
                     },
                     fs.createReadStream(fname),
-                    function(err) {
+                    function (err) {
                         expect(err).to.not.exist;
                         client.close();
                     }
                 );
             });
 
             client.on('end', done);
         });
     });
 
-    describe('Login tests', function() {
+    describe('Login tests', function () {
         this.timeout(10 * 1000);
 
         let server,
             lmtpServer,
             client,
             lmtpClient,
             testtoken = 'testtoken';
 
-        beforeEach(function(done) {
+        beforeEach(function (done) {
             server = new SMTPServer({
                 authMethods: ['PLAIN', 'XOAUTH2'],
                 disabledCommands: ['STARTTLS'],
 
                 size: 100 * 1024,
 
-                onData: function(stream, session, callback) {
+                onData: function (stream, session, callback) {
                     let err = false;
-                    stream.on('data', function(chunk) {
+                    stream.on('data', function (chunk) {
                         if (err || session.use8BitMime) {
                             return;
                         }
                         for (let i = 0, len = chunk.length; i < len; i++) {
                             if (chunk[i] >= 0x80) {
                                 err = new Error('8 bit content not allowed');
                             }
                         }
                     });
-                    stream.on('end', function() {
+                    stream.on('end', function () {
                         callback(err, false);
                     });
                 },
 
-                onAuth: function(auth, session, callback) {
+                onAuth: function (auth, session, callback) {
                     if (auth.method !== 'XOAUTH2') {
                         if (auth.username !== 'testuser' || auth.password !== 'testpass') {
                             return callback(new Error('Invalid username or password'));
                         }
                     } else if (auth.username !== 'testuser' || auth.accessToken !== testtoken) {
@@ -488,11 +483,11 @@ describe('SMTP-Connection Tests', function() {
                     }
                     callback(null, {
                         user: 123
                     });
                 },
-                onMailFrom: function(address, session, callback) {
+                onMailFrom: function (address, session, callback) {
                     if (address.args && parseInt(address.args.SIZE, 10) > 50 * 1024) {
                         return callback(new Error('452 Insufficient channel storage: ' + address.address));
                     }
 
                     if (!/@valid.sender/.test(address.address)) {
@@ -511,11 +506,11 @@ describe('SMTP-Connection Tests', function() {
                         return callback(new Error('Trying to use Unicode address without declaring SMTPUTF8 first'));
                     }
 
                     return callback(); // Accept the address
                 },
-                onRcptTo: function(address, session, callback) {
+                onRcptTo: function (address, session, callback) {
                     if (!/@valid.recipient/.test(address.address)) {
                         return callback(new Error('Only user@valid.recipient is allowed to receive mail'));
                     }
                     if (/[\x80-\uFFFF]/.test(address.address) && !session.smtpUtf8) {
                         return callback(new Error('Trying to use Unicode address without declaring SMTPUTF8 first'));
@@ -527,30 +522,30 @@ describe('SMTP-Connection Tests', function() {
 
             lmtpServer = new SMTPServer({
                 lmtp: true,
                 disabledCommands: ['STARTTLS', 'AUTH'],
 
-                onData: function(stream, session, callback) {
-                    stream.on('data', function() {});
-                    stream.on('end', function() {
-                        let response = session.envelope.rcptTo.map(function(rcpt, i) {
+                onData: function (stream, session, callback) {
+                    stream.on('data', function () {});
+                    stream.on('end', function () {
+                        let response = session.envelope.rcptTo.map(function (rcpt, i) {
                             if (i % 2) {
                                 return '<' + rcpt.address + '> Accepted';
                             } else {
                                 return new Error('<' + rcpt.address + '> Not accepted');
                             }
                         });
                         callback(null, response);
                     });
                 },
-                onMailFrom: function(address, session, callback) {
+                onMailFrom: function (address, session, callback) {
                     if (!/@valid.sender/.test(address.address)) {
                         return callback(new Error('Only user@valid.sender is allowed to send mail'));
                     }
                     return callback(); // Accept the address
                 },
-                onRcptTo: function(address, session, callback) {
+                onRcptTo: function (address, session, callback) {
                     if (!/@valid.recipient/.test(address.address)) {
                         return callback(new Error('Only user@valid.recipient is allowed to receive mail'));
                     }
                     return callback(); // Accept the address
                 },
@@ -568,163 +563,163 @@ describe('SMTP-Connection Tests', function() {
                 lmtp: true,
                 logger: false,
                 debug: false
             });
 
-            server.listen(PORT_NUMBER, function() {
-                lmtpServer.listen(LMTP_PORT_NUMBER, function() {
-                    client.connect(function() {
+            server.listen(PORT_NUMBER, function () {
+                lmtpServer.listen(LMTP_PORT_NUMBER, function () {
+                    client.connect(function () {
                         lmtpClient.connect(done);
                     });
                 });
             });
         });
 
-        afterEach(function(done) {
+        afterEach(function (done) {
             client.close();
             lmtpClient.close();
-            server.close(function() {
+            server.close(function () {
                 lmtpServer.close(done);
             });
         });
 
-        it('should login', function(done) {
+        it('should login', function (done) {
             expect(client.authenticated).to.be.false;
             client.login(
                 {
                     user: 'testuser',
                     credentials: {
                         user: 'testuser',
                         pass: 'testpass'
                     }
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.not.exist;
                     expect(client.authenticated).to.be.true;
                     done();
                 }
             );
         });
 
-        it('should return error for invalid login', function(done) {
+        it('should return error for invalid login', function (done) {
             expect(client.authenticated).to.be.false;
             client.login(
                 {
                     user: 'testuser',
                     credentials: {
                         user: 'testuser',
                         pass: 'invalid'
                     }
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.exist;
                     expect(client.authenticated).to.be.false;
                     expect(err.code).to.equal('EAUTH');
                     expect(err.responseCode).to.equal(535);
                     done();
                 }
             );
         });
 
-        it('should return error for missing credentials', function(done) {
+        it('should return error for missing credentials', function (done) {
             expect(client.authenticated).to.be.false;
             client.login(
                 {
                     user: 'testuser'
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.exist;
                     expect(client.authenticated).to.be.false;
                     expect(err.message).to.match(/^Missing credentials/);
                     expect(err.code).to.equal('EAUTH');
                     expect(err.response).to.be.undefined;
                     done();
                 }
             );
         });
 
-        it('should return error for incomplete credentials', function(done) {
+        it('should return error for incomplete credentials', function (done) {
             expect(client.authenticated).to.be.false;
             client.login(
                 {
                     user: 'testuser',
                     credentials: {
                         user: 'testuser'
                     }
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.exist;
                     expect(client.authenticated).to.be.false;
                     expect(err.message).to.match(/^Missing credentials/);
                     expect(err.code).to.equal('EAUTH');
                     expect(err.response).to.be.undefined;
                     done();
                 }
             );
         });
 
-        describe('xoauth2 login', function() {
+        describe('xoauth2 login', function () {
             this.timeout(10 * 1000);
             let x2server;
 
-            beforeEach(function(done) {
+            beforeEach(function (done) {
                 x2server = xoauth2Server({
                     port: XOAUTH_PORT,
-                    onUpdate: function(username, accessToken) {
+                    onUpdate: function (username, accessToken) {
                         testtoken = accessToken;
                     }.bind(this)
                 });
 
                 x2server.addUser('testuser', 'refresh-token');
 
                 x2server.start(done);
             });
 
-            afterEach(function(done) {
+            afterEach(function (done) {
                 x2server.stop(done);
             });
 
-            it('should login with xoauth2 string', function(done) {
+            it('should login with xoauth2 string', function (done) {
                 expect(client.authenticated).to.be.false;
                 client.login(
                     {
                         type: 'oauth2',
                         user: 'testuser',
                         oauth2: new XOAuth2({
                             user: 'testuser',
                             accessToken: testtoken
                         })
                     },
-                    function(err) {
+                    function (err) {
                         expect(err).to.not.exist;
                         expect(client.authenticated).to.be.true;
                         done();
                     }
                 );
             });
 
-            it('should return error for invalid xoauth2 string token', function(done) {
+            it('should return error for invalid xoauth2 string token', function (done) {
                 expect(client.authenticated).to.be.false;
                 client.login(
                     {
                         type: 'oauth2',
                         user: 'testuser',
                         oauth2: new XOAuth2({
                             user: 'testuser',
                             accessToken: 'invalid'
                         })
                     },
-                    function(err) {
+                    function (err) {
                         expect(err).to.exist;
                         expect(client.authenticated).to.be.false;
                         expect(err.code).to.equal('EAUTH');
                         done();
                     }
                 );
             });
 
-            it('should login with xoauth2 object', function(done) {
+            it('should login with xoauth2 object', function (done) {
                 expect(client.authenticated).to.be.false;
                 client.login(
                     {
                         type: 'oauth2',
                         user: 'testuser',
@@ -735,19 +730,19 @@ describe('SMTP-Connection Tests', function() {
                             refreshToken: 'refresh-token',
                             accessToken: 'uuuuu',
                             accessUrl: 'http://localhost:' + XOAUTH_PORT
                         })
                     },
-                    function(err) {
+                    function (err) {
                         expect(err).to.not.exist;
                         expect(client.authenticated).to.be.true;
                         done();
                     }
                 );
             });
 
-            it('should fail with xoauth2 object', function(done) {
+            it('should fail with xoauth2 object', function (done) {
                 expect(client.authenticated).to.be.false;
                 client.login(
                     {
                         type: 'oauth2',
                         user: 'testuser',
@@ -758,19 +753,19 @@ describe('SMTP-Connection Tests', function() {
                             refreshToken: 'refrsesh-token',
                             accessToken: 'uuuuu',
                             accessUrl: 'http://localhost:' + XOAUTH_PORT
                         })
                     },
-                    function(err) {
+                    function (err) {
                         expect(err).to.exist;
                         expect(client.authenticated).to.be.false;
                         done();
                     }
                 );
             });
 
-            it('should fail with invalid xoauth2 response', function(done) {
+            it('should fail with invalid xoauth2 response', function (done) {
                 expect(client.authenticated).to.be.false;
 
                 let oauth2 = new XOAuth2({
                     user: 'testuser',
                     clientId: '{Client ID}',
@@ -786,24 +781,24 @@ describe('SMTP-Connection Tests', function() {
                     {
                         type: 'oauth2',
                         user: 'testuser',
                         oauth2
                     },
-                    function(err) {
+                    function (err) {
                         expect(err).to.exist;
                         expect(client.authenticated).to.be.false;
 
                         oauth2.generateToken.restore();
                         done();
                     }
                 );
             });
         });
 
-        describe('custom login', function() {
+        describe('custom login', function () {
             let customClient;
-            beforeEach(function(done) {
+            beforeEach(function (done) {
                 customClient = new SMTPConnection({
                     port: PORT_NUMBER,
                     logger: false,
                     debug: false,
                     customAuth: {
@@ -822,55 +817,55 @@ describe('SMTP-Connection Tests', function() {
                 });
 
                 customClient.connect(done);
             });
 
-            afterEach(function(done) {
+            afterEach(function (done) {
                 customClient.close();
                 done();
             });
 
-            it('should login', function(done) {
+            it('should login', function (done) {
                 expect(customClient.authenticated).to.be.false;
                 customClient.login(
                     {
                         method: 'mytest',
                         user: 'testuser',
                         credentials: {
                             user: 'testuser',
                             pass: 'testpass'
                         }
                     },
-                    function(err) {
+                    function (err) {
                         expect(err).to.not.exist;
                         expect(customClient.authenticated).to.be.true;
                         done();
                     }
                 );
             });
         });
 
-        describe('Send without PIPELINING', function() {
-            beforeEach(function(done) {
-                client.on('end', function() {
+        describe('Send without PIPELINING', function () {
+            beforeEach(function (done) {
+                client.on('end', function () {
                     client = new SMTPConnection({
                         port: PORT_NUMBER,
                         logger: false,
                         debug: false
                     });
                     // disable PIPELINING
                     server.options.hidePIPELINING = true;
-                    client.connect(function() {
+                    client.connect(function () {
                         client.login(
                             {
                                 user: 'testuser',
                                 credentials: {
                                     user: 'testuser',
                                     pass: 'testpass'
                                 }
                             },
-                            function(err) {
+                            function (err) {
                                 expect(err).to.not.exist;
                                 // enable PIPELINING
                                 server.options.hidePIPELINING = false;
                                 done();
                             }
@@ -878,18 +873,18 @@ describe('SMTP-Connection Tests', function() {
                     });
                 });
                 client.close();
             });
 
-            it('should send only to valid recipients without PIPELINING', function(done) {
+            it('should send only to valid recipients without PIPELINING', function (done) {
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: ['test1@valid.recipient', 'test2@invalid.recipient', 'test3@valid.recipient']
                     },
                     'test',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.not.exist;
                         expect(info).to.deep.equal({
                             accepted: ['test1@valid.recipient', 'test3@valid.recipient'],
                             rejected: ['test2@invalid.recipient'],
                             rejectedErrors: info.rejectedErrors,
@@ -903,35 +898,35 @@ describe('SMTP-Connection Tests', function() {
                     }
                 );
             });
         });
 
-        describe('Send messages', function() {
-            beforeEach(function(done) {
+        describe('Send messages', function () {
+            beforeEach(function (done) {
                 client.login(
                     {
                         user: 'testuser',
                         credentials: {
                             user: 'testuser',
                             pass: 'testpass'
                         }
                     },
-                    function(err) {
+                    function (err) {
                         expect(err).to.not.exist;
                         done();
                     }
                 );
             });
 
-            it('should send message', function(done) {
+            it('should send message', function (done) {
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: 'test@valid.recipient'
                     },
                     'test',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.not.exist;
                         expect(info).to.deep.equal({
                             accepted: ['test@valid.recipient'],
                             rejected: [],
                             envelopeTime: info.envelopeTime,
@@ -942,37 +937,37 @@ describe('SMTP-Connection Tests', function() {
                         done();
                     }
                 );
             });
 
-            it('should send multiple messages', function(done) {
+            it('should send multiple messages', function (done) {
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: 'test@valid.recipient'
                     },
                     'test',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.not.exist;
                         expect(info).to.deep.equal({
                             accepted: ['test@valid.recipient'],
                             rejected: [],
                             envelopeTime: info.envelopeTime,
                             messageTime: info.messageTime,
                             messageSize: info.messageSize,
                             response: '250 OK: message queued'
                         });
-                        client.reset(function(err) {
+                        client.reset(function (err) {
                             expect(err).to.not.exist;
 
                             client.send(
                                 {
                                     from: 'test2@valid.sender',
                                     to: 'test2@valid.recipient'
                                 },
                                 'test2',
-                                function(err, info) {
+                                function (err, info) {
                                     expect(err).to.not.exist;
                                     expect(info).to.deep.equal({
                                         accepted: ['test2@valid.recipient'],
                                         rejected: [],
                                         envelopeTime: info.envelopeTime,
@@ -986,18 +981,18 @@ describe('SMTP-Connection Tests', function() {
                         });
                     }
                 );
             });
 
-            it('should send only to valid recipients', function(done) {
+            it('should send only to valid recipients', function (done) {
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: ['test1@valid.recipient', 'test2@invalid.recipient', 'test3@valid.recipient']
                     },
                     'test',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.not.exist;
                         expect(info).to.deep.equal({
                             accepted: ['test1@valid.recipient', 'test3@valid.recipient'],
                             rejected: ['test2@invalid.recipient'],
                             rejectedErrors: info.rejectedErrors,
@@ -1010,68 +1005,68 @@ describe('SMTP-Connection Tests', function() {
                         done();
                     }
                 );
             });
 
-            it('should reject all recipients', function(done) {
+            it('should reject all recipients', function (done) {
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: ['test1@invalid.recipient', 'test2@invalid.recipient', 'test3@invalid.recipient']
                     },
                     'test',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.exist;
                         expect(info).to.not.exist;
                         expect(err.rejected).to.deep.equal(['test1@invalid.recipient', 'test2@invalid.recipient', 'test3@invalid.recipient']);
                         expect(err.rejectedErrors.length).to.equal(3);
                         done();
                     }
                 );
             });
 
-            it('should reject too large SIZE arguments', function(done) {
+            it('should reject too large SIZE arguments', function (done) {
                 client.send(
                     {
                         from: 'test2@valid.sender',
                         to: 'test2@valid.recipient',
                         size: 1024 * 1024
                     },
                     'test',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.exist;
                         expect(info).to.not.exist;
                         done();
                     }
                 );
             });
 
-            it('should reject too large message', function(done) {
+            it('should reject too large message', function (done) {
                 client.send(
                     {
                         from: 'test2@valid.sender',
                         to: 'test2@valid.recipient',
                         size: 70 * 1024
                     },
                     'test',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.exist;
                         expect(info).to.not.exist;
                         done();
                     }
                 );
             });
 
-            it('should declare SIZE', function(done) {
+            it('should declare SIZE', function (done) {
                 client.send(
                     {
                         from: 'test2@valid.sender',
                         to: 'test2@valid.recipient',
                         size: 10 * 1024
                     },
                     'test',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.not.exist;
                         expect(info).to.deep.equal({
                             accepted: ['test2@valid.recipient'],
                             rejected: [],
                             envelopeTime: info.envelopeTime,
@@ -1082,11 +1077,11 @@ describe('SMTP-Connection Tests', function() {
                         done();
                     }
                 );
             });
 
-            it('lmtp should send only to valid recipients', function(done) {
+            it('lmtp should send only to valid recipients', function (done) {
                 lmtpClient.send(
                     {
                         from: 'test@valid.sender',
                         to: [
                             'test1@valid.recipient',
@@ -1096,11 +1091,11 @@ describe('SMTP-Connection Tests', function() {
                             'test5@valid.recipient',
                             'test6@valid.recipient'
                         ]
                     },
                     'test',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.not.exist;
                         expect(info.accepted).to.deep.equal(['test3@valid.recipient', 'test5@valid.recipient']);
                         expect(info.rejected).to.deep.equal([
                             'test2@invalid.recipient',
                             'test1@valid.recipient',
@@ -1111,18 +1106,18 @@ describe('SMTP-Connection Tests', function() {
                         done();
                     }
                 );
             });
 
-            it('should send using SMTPUTF8', function(done) {
+            it('should send using SMTPUTF8', function (done) {
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: ['test1@valid.recipient', 'test2@invalid.recipient', 'test3õ@valid.recipient']
                     },
                     'test',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.not.exist;
                         expect(info).to.deep.equal({
                             accepted: ['test1@valid.recipient', 'test3õ@valid.recipient'],
                             rejected: ['test2@invalid.recipient'],
                             rejectedErrors: info.rejectedErrors,
@@ -1134,19 +1129,19 @@ describe('SMTP-Connection Tests', function() {
                         done();
                     }
                 );
             });
 
-            it('should send using 8BITMIME', function(done) {
+            it('should send using 8BITMIME', function (done) {
                 client.send(
                     {
                         use8BitMime: true,
                         from: 'test@valid.sender',
                         to: ['test1@valid.recipient', 'test2@invalid.recipient', 'test3õ@valid.recipient']
                     },
                     'õõõõ',
-                    function(err, info) {
+                    function (err, info) {
                         expect(err).to.not.exist;
                         expect(info).to.deep.equal({
                             accepted: ['test1@valid.recipient', 'test3õ@valid.recipient'],
                             rejected: ['test2@invalid.recipient'],
                             rejectedErrors: info.rejectedErrors,
@@ -1158,77 +1153,77 @@ describe('SMTP-Connection Tests', function() {
                         done();
                     }
                 );
             });
 
-            it('should receive error for 8-bit content without 8BITMIME declaration', function(done) {
+            it('should receive error for 8-bit content without 8BITMIME declaration', function (done) {
                 client.send(
                     {
                         use8BitMime: false,
                         from: 'test@valid.sender',
                         to: ['test1@valid.recipient', 'test2@invalid.recipient', 'test3õ@valid.recipient']
                     },
                     'õõõõ',
-                    function(err) {
+                    function (err) {
                         expect(/8 bit content not allowed/.test(err.message)).to.be.true;
                         done();
                     }
                 );
             });
 
-            it('should return error for invalidly formatted recipients', function(done) {
+            it('should return error for invalidly formatted recipients', function (done) {
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: ['test@valid.recipient', '"address\r\n with folding"@valid.recipient']
                     },
                     'test',
-                    function(err) {
+                    function (err) {
                         expect(/^Invalid recipient/.test(err.message)).to.be.true;
                         done();
                     }
                 );
             });
 
-            it('should return error for no valid recipients', function(done) {
+            it('should return error for no valid recipients', function (done) {
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: ['test1@invalid.recipient', 'test2@invalid.recipient', 'test3@invalid.recipient']
                     },
                     'test',
-                    function(err) {
+                    function (err) {
                         expect(err).to.exist;
                         done();
                     }
                 );
             });
 
-            it('should return error for invalid sender', function(done) {
+            it('should return error for invalid sender', function (done) {
                 client.send(
                     {
                         from: 'test@invalid.sender',
                         to: 'test@valid.recipient'
                     },
                     'test',
-                    function(err) {
+                    function (err) {
                         expect(err).to.exist;
                         done();
                     }
                 );
             });
 
-            it('should send message string', function(done) {
+            it('should send message string', function (done) {
                 let chunks = [],
                     message = new Array(1024).join('teretere, vana kere\n');
 
-                server.on('data', function(connection, chunk) {
+                server.on('data', function (connection, chunk) {
                     chunks.push(chunk);
                 });
 
                 server.removeAllListeners('dataReady');
-                server.on('dataReady', function(connection, callback) {
+                server.on('dataReady', function (connection, callback) {
                     let body = Buffer.concat(chunks);
                     expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n'));
                     callback(null, 'ABC1');
                 });
 
@@ -1236,93 +1231,83 @@ describe('SMTP-Connection Tests', function() {
                     {
                         from: 'test@valid.sender',
                         to: 'test@valid.recipient'
                     },
                     message,
-                    function(err) {
+                    function (err) {
                         expect(err).to.not.exist;
                         done();
                     }
                 );
             });
 
-            it('should send message buffer', function(done) {
+            it('should send message buffer', function (done) {
                 let chunks = [],
                     message = Buffer.from(new Array(1024).join('teretere, vana kere\n'));
 
-                server.on('data', function(connection, chunk) {
+                server.on('data', function (connection, chunk) {
                     chunks.push(chunk);
                 });
 
                 server.removeAllListeners('dataReady');
-                server.on('dataReady', function(connection, callback) {
+                server.on('dataReady', function (connection, callback) {
                     let body = Buffer.concat(chunks);
-                    expect(body.toString()).to.equal(
-                        message
-                            .toString()
-                            .trim()
-                            .replace(/\n/g, '\r\n')
-                    );
+                    expect(body.toString()).to.equal(message.toString().trim().replace(/\n/g, '\r\n'));
                     callback(null, 'ABC1');
                 });
 
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: 'test@valid.recipient'
                     },
                     message,
-                    function(err) {
+                    function (err) {
                         expect(err).to.not.exist;
                         done();
                     }
                 );
             });
 
-            it('should send message stream', function(done) {
+            it('should send message stream', function (done) {
                 let chunks = [],
                     fname = __dirname + '/../../LICENSE',
                     message = fs.readFileSync(fname, 'utf-8');
 
-                server.on('data', function(connection, chunk) {
+                server.on('data', function (connection, chunk) {
                     chunks.push(chunk);
                 });
 
                 server.removeAllListeners('dataReady');
-                server.on('dataReady', function(connection, callback) {
+                server.on('dataReady', function (connection, callback) {
                     let body = Buffer.concat(chunks);
-                    expect(body.toString()).to.equal(
-                        message
-                            .toString()
-                            .trim()
-                            .replace(/\n/g, '\r\n')
-                    );
+                    expect(body.toString()).to.equal(message.toString().trim().replace(/\n/g, '\r\n'));
                     callback(null, 'ABC1');
                 });
 
                 client.send(
                     {
                         from: 'test@valid.sender',
                         to: 'test@valid.recipient'
                     },
                     fs.createReadStream(fname),
-                    function(err) {
+                    function (err) {
                         expect(err).to.not.exist;
                         done();
                     }
                 );
             });
         });
     });
 });
 
 function proxyConnect(port, host, destinationPort, destinationHost, callback) {
-    let socket = net.connect(port, host, function() {
+    let socket = net.connect(port, host, function () {
         socket.write('CONNECT ' + destinationHost + ':' + destinationPort + ' HTTP/1.1\r\n\r\n');
 
         let headers = '';
-        let onSocketData = function(chunk) {
+        let onSocketData = function (chunk) {
             let match;
             let remainder;
 
             headers += chunk.toString('binary');
             if ((match = headers.match(/\r\n\r\n/))) {
@@ -1337,9 +1322,9 @@ function proxyConnect(port, host, destinationPort, destinationHost, callback) {
             }
         };
         socket.on('data', onSocketData);
     });
 
-    socket.on('error', function(err) {
+    socket.on('error', function (err) {
         expect(err).to.not.exist;
     });
 }
diff --git a/test/smtp-connection/xoauth2-mock-server.js b/test/smtp-connection/xoauth2-mock-server.js
index 5fbef7b..d675237 100644
--- a/test/smtp-connection/xoauth2-mock-server.js
+++ b/test/smtp-connection/xoauth2-mock-server.js
@@ -2,11 +2,11 @@
 
 const http = require('http');
 const crypto = require('crypto');
 const querystring = require('querystring');
 
-module.exports = function(options) {
+module.exports = function (options) {
     return new OAuthServer(options);
 };
 
 function OAuthServer(options) {
     this.options = options || {};
@@ -15,11 +15,11 @@ function OAuthServer(options) {
 
     this.options.port = Number(this.options.port) || 3080;
     this.options.expiresIn = Number(this.options.expiresIn) || 3600;
 }
 
-OAuthServer.prototype.addUser = function(username, refreshToken) {
+OAuthServer.prototype.addUser = function (username, refreshToken) {
     let user = {
         username,
         refreshToken: refreshToken || crypto.randomBytes(10).toString('base64')
     };
 
@@ -27,11 +27,11 @@ OAuthServer.prototype.addUser = function(username, refreshToken) {
     this.tokens[user.refreshToken] = username;
 
     return this.generateAccessToken(user.refreshToken);
 };
 
-OAuthServer.prototype.generateAccessToken = function(refreshToken) {
+OAuthServer.prototype.generateAccessToken = function (refreshToken) {
     let username = this.tokens[refreshToken],
         accessToken = crypto.randomBytes(10).toString('base64');
 
     if (!username) {
         return {
@@ -51,19 +51,19 @@ OAuthServer.prototype.generateAccessToken = function(refreshToken) {
         expires_in: this.options.expiresIn,
         token_type: 'Bearer'
     };
 };
 
-OAuthServer.prototype.validateAccessToken = function(username, accessToken) {
+OAuthServer.prototype.validateAccessToken = function (username, accessToken) {
     if (!this.users[username] || this.users[username].accessToken !== accessToken || this.users[username].expiresIn < Date.now()) {
         return false;
     } else {
         return true;
     }
 };
 
-OAuthServer.prototype.start = function(callback) {
+OAuthServer.prototype.start = function (callback) {
     this.server = http.createServer((req, res) => {
         let data = [],
             datalen = 0;
         req.on('data', chunk => {
             if (!chunk || !chunk.length) {
@@ -86,8 +86,8 @@ OAuthServer.prototype.start = function(callback) {
     });
 
     this.server.listen(this.options.port, callback);
 };
 
-OAuthServer.prototype.stop = function(callback) {
+OAuthServer.prototype.stop = function (callback) {
     this.server.close(callback);
 };
diff --git a/test/smtp-pool/smtp-pool-test.js b/test/smtp-pool/smtp-pool-test.js
index 7a4536a..163339c 100644
--- a/test/smtp-pool/smtp-pool-test.js
+++ b/test/smtp-pool/smtp-pool-test.js
@@ -39,22 +39,22 @@ class MockBuilder {
     getHeader() {
         return 'teretere';
     }
 }
 
-describe('SMTP Pool Tests', function() {
+describe('SMTP Pool Tests', function () {
     this.timeout(100 * 1000); //eslint-disable-line no-invalid-this
 
     let server;
 
-    beforeEach(function(done) {
+    beforeEach(function (done) {
         server = new SMTPServer({
             authMethods: ['PLAIN', 'XOAUTH2'],
             disabledCommands: ['STARTTLS'],
 
             onData(stream, session, callback) {
-                stream.on('data', function() {});
+                stream.on('data', function () {});
                 stream.on('end', callback);
             },
 
             onAuth(auth, session, callback) {
                 if (auth.method !== 'XOAUTH2') {
@@ -93,30 +93,30 @@ describe('SMTP Pool Tests', function() {
         });
 
         server.listen(PORT_NUMBER, done);
     });
 
-    afterEach(function(done) {
+    afterEach(function (done) {
         server.close(done);
     });
 
-    it('Should expose version number', function() {
+    it('Should expose version number', function () {
         let pool = new SMTPPool();
         expect(pool.name).to.exist;
         expect(pool.version).to.exist;
     });
 
-    it('Should detect wellknown data', function() {
+    it('Should detect wellknown data', function () {
         let pool = new SMTPPool({
             service: 'google mail'
         });
         expect(pool.options.host).to.equal('smtp.gmail.com');
         expect(pool.options.port).to.equal(465);
         expect(pool.options.secure).to.be.true;
     });
 
-    it('should send mail', function(done) {
+    it('should send mail', function (done) {
         let pool = new SMTPPool({
             port: PORT_NUMBER,
             auth: {
                 user: 'testuser',
                 pass: 'testpass'
@@ -125,16 +125,16 @@ describe('SMTP Pool Tests', function() {
             debug: true
         });
 
         let message = new Array(1024).join('teretere, vana kere\n');
 
-        server.onData = function(stream, session, callback) {
+        server.onData = function (stream, session, callback) {
             let chunks = [];
-            stream.on('data', function(chunk) {
+            stream.on('data', function (chunk) {
                 chunks.push(chunk);
             });
-            stream.on('end', function() {
+            stream.on('end', function () {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n') + '\r\n');
                 callback();
             });
         };
@@ -148,28 +148,28 @@ describe('SMTP Pool Tests', function() {
                         to: 'test@valid.recipient'
                     },
                     message
                 )
             },
-            function(err) {
+            function (err) {
                 expect(err).to.not.exist;
                 pool.close();
                 done();
             }
         );
     });
 
-    it('should send multiple mails', function(done) {
+    it('should send multiple mails', function (done) {
         let pool = new SMTPPool('smtp://testuser:testpass@localhost:' + PORT_NUMBER + '/?logger=false');
         let message = new Array(10 * 1024).join('teretere, vana kere\n');
 
-        server.onData = function(stream, session, callback) {
+        server.onData = function (stream, session, callback) {
             let chunks = [];
-            stream.on('data', function(chunk) {
+            stream.on('data', function (chunk) {
                 chunks.push(chunk);
             });
-            stream.on('end', function() {
+            stream.on('end', function () {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n') + '\r\n');
                 callback();
             });
         };
@@ -184,25 +184,25 @@ describe('SMTP Pool Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.not.exist;
                     callback();
                 }
             );
         }
 
         let total = 100;
         let returned = 0;
-        let cb = function() {
+        let cb = function () {
             let sent = 0;
 
             if (++returned === total) {
                 expect(pool._connections.length).to.be.above(1);
-                pool._connections.forEach(function(conn) {
+                pool._connections.forEach(function (conn) {
                     expect(conn.messages).to.be.above(1);
                     sent += conn.messages;
                 });
 
                 expect(sent).to.be.equal(total);
@@ -214,27 +214,27 @@ describe('SMTP Pool Tests', function() {
         for (let i = 0; i < total; i++) {
             sendMessage(cb);
         }
     });
 
-    it('should tolerate connection errors', function(done) {
+    it('should tolerate connection errors', function (done) {
         let pool = new SMTPPool({
             port: PORT_NUMBER,
             auth: {
                 user: 'testuser',
                 pass: 'testpass'
             },
             logger: false
         });
         let message = new Array(10 * 1024).join('teretere, vana kere\n');
 
-        server.onData = function(stream, session, callback) {
+        server.onData = function (stream, session, callback) {
             let chunks = [];
-            stream.on('data', function(chunk) {
+            stream.on('data', function (chunk) {
                 chunks.push(chunk);
             });
-            stream.on('end', function() {
+            stream.on('end', function () {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n') + '\r\n');
                 callback();
             });
         };
@@ -252,11 +252,11 @@ describe('SMTP Pool Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err) {
+                function (err) {
                     if (isErr) {
                         expect(err).to.exist;
                     } else {
                         expect(err).to.not.exist;
                     }
@@ -266,22 +266,22 @@ describe('SMTP Pool Tests', function() {
             );
         }
 
         let total = 100;
         let returned = 0;
-        let cb = function() {
+        let cb = function () {
             if (++returned === total) {
                 pool.close();
                 return done();
             }
         };
         for (let i = 0; i < total; i++) {
             sendMessage(cb);
         }
     });
 
-    it('should tolerate idle connections and re-assign messages to other connections', function(done) {
+    it('should tolerate idle connections and re-assign messages to other connections', function (done) {
         let pool = new SMTPPool({
             port: PORT_NUMBER,
             auth: {
                 user: 'testuser',
                 pass: 'testpass'
@@ -292,26 +292,26 @@ describe('SMTP Pool Tests', function() {
         let total = 20;
         let message = new Array(10 * 1024).join('teretere, vana kere\n');
         let sentMessages = 0;
         let killedConnections = false;
 
-        server.onData = function(stream, session, callback) {
+        server.onData = function (stream, session, callback) {
             let callCallback = true;
 
-            stream.on('data', function() {
+            stream.on('data', function () {
                 // If we hit half the messages, simulate the server closing connections
                 // that are open for long time
                 if (!killedConnections && sentMessages === total / 2) {
                     killedConnections = true;
                     callCallback = false;
-                    server.connections.forEach(function(connection) {
+                    server.connections.forEach(function (connection) {
                         connection._socket.end();
                     });
                 }
             });
 
-            stream.on('end', function() {
+            stream.on('end', function () {
                 if (callCallback) {
                     sentMessages += 1;
                     return callback();
                 }
             });
@@ -327,11 +327,11 @@ describe('SMTP Pool Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err) {
+                function (err) {
                     if (err) {
                         expect(err.message).to.equal('Connection closed unexpectedly');
                     }
                     callback();
                 }
@@ -340,11 +340,11 @@ describe('SMTP Pool Tests', function() {
 
         // Send 10 messages in a row.. then wait a bit and send 10 more
         // When we wait a bit.. the server will kill the "idle" connections
         // so that we can ensure the pool will handle it properly
         let returned = 0;
-        let cb = function() {
+        let cb = function () {
             returned++;
 
             if (returned === total) {
                 pool.close();
                 return done();
@@ -360,11 +360,11 @@ describe('SMTP Pool Tests', function() {
         }
 
         sendHalfBulk();
     });
 
-    it('should call back with connection errors to senders having messages in flight', function(done) {
+    it('should call back with connection errors to senders having messages in flight', function (done) {
         let pool = new SMTPPool({
             maxConnections: 1,
             socketTimeout: 200,
             port: PORT_NUMBER,
             auth: {
@@ -384,11 +384,11 @@ describe('SMTP Pool Tests', function() {
                         to: 'test@valid.recipient'
                     },
                     message
                 )
             },
-            function(err) {
+            function (err) {
                 expect(err).not.to.exist;
             }
         );
 
         pool.send(
@@ -400,28 +400,28 @@ describe('SMTP Pool Tests', function() {
                         to: 'test+timeout@valid.recipient'
                     },
                     message
                 )
             },
-            function(err) {
+            function (err) {
                 expect(err).to.exist;
                 pool.close();
                 done();
             }
         );
     });
 
-    it('should not send more then allowed for one connection', function(done) {
+    it('should not send more then allowed for one connection', function (done) {
         let pool = new SMTPPool('smtp://testuser:testpass@localhost:' + PORT_NUMBER + '/?maxConnections=1&maxMessages=5&logger=false');
         let message = new Array(10 * 1024).join('teretere, vana kere\n');
 
-        server.onData = function(stream, session, callback) {
+        server.onData = function (stream, session, callback) {
             let chunks = [];
-            stream.on('data', function(chunk) {
+            stream.on('data', function (chunk) {
                 chunks.push(chunk);
             });
-            stream.on('end', function() {
+            stream.on('end', function () {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n') + '\r\n');
                 callback();
             });
         };
@@ -436,20 +436,20 @@ describe('SMTP Pool Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.not.exist;
                     callback();
                 }
             );
         }
 
         let total = 100;
         let returned = 0;
-        let cb = function() {
+        let cb = function () {
             if (++returned === total) {
                 expect(pool._connections.length).to.be.equal(1);
                 expect(pool._connections[0].messages).to.be.below(6);
                 pool.close();
                 return done();
@@ -458,11 +458,11 @@ describe('SMTP Pool Tests', function() {
         for (let i = 0; i < total; i++) {
             sendMessage(cb);
         }
     });
 
-    it('should send multiple mails with rate limit', function(done) {
+    it('should send multiple mails with rate limit', function (done) {
         let pool = new SMTPPool({
             port: PORT_NUMBER,
             auth: {
                 user: 'testuser',
                 pass: 'testpass'
@@ -472,16 +472,16 @@ describe('SMTP Pool Tests', function() {
             logger: false
         });
         let message = 'teretere, vana kere\n';
         let startTime = Date.now();
 
-        server.onData = function(stream, session, callback) {
+        server.onData = function (stream, session, callback) {
             let chunks = [];
-            stream.on('data', function(chunk) {
+            stream.on('data', function (chunk) {
                 chunks.push(chunk);
             });
-            stream.on('end', function() {
+            stream.on('end', function () {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n') + '\r\n');
                 callback();
             });
         };
@@ -496,51 +496,51 @@ describe('SMTP Pool Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.not.exist;
                     callback();
                 }
             );
         }
 
         let total = 5000;
         let returned = 0;
-        let cb = function() {
+        let cb = function () {
             if (++returned === total) {
                 let endTime = Date.now();
                 expect(endTime - startTime).to.be.at.least(24000);
 
                 pool.close();
                 return done();
             }
         };
 
         let i = 0;
-        let send = function() {
+        let send = function () {
             if (i++ >= total) {
                 return;
             }
             sendMessage(cb);
             setImmediate(send);
         };
 
         send();
     });
 
-    it('should return pending messages once closed', function(done) {
+    it('should return pending messages once closed', function (done) {
         let pool = new SMTPPool('smtp://testuser:testpass@localhost:' + PORT_NUMBER + '/?maxConnections=1&logger=false');
         let message = new Array(10 * 1024).join('teretere, vana kere\n');
 
-        server.onData = function(stream, session, callback) {
+        server.onData = function (stream, session, callback) {
             let chunks = [];
-            stream.on('data', function(chunk) {
+            stream.on('data', function (chunk) {
                 chunks.push(chunk);
             });
-            stream.on('end', function() {
+            stream.on('end', function () {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n') + '\r\n');
                 callback();
             });
         };
@@ -555,40 +555,40 @@ describe('SMTP Pool Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.exist;
                     callback();
                 }
             );
         }
 
         let total = 100;
         let returned = 0;
-        let cb = function() {
+        let cb = function () {
             if (++returned === total) {
                 return done();
             }
         };
         for (let i = 0; i < total; i++) {
             sendMessage(cb);
         }
         pool.close();
     });
 
-    it('should emit idle for free slots in the pool', function(done) {
+    it('should emit idle for free slots in the pool', function (done) {
         let pool = new SMTPPool('smtp://testuser:testpass@localhost:' + PORT_NUMBER + '/?logger=false');
         let message = new Array(10 * 1024).join('teretere, vana kere\n');
 
-        server.onData = function(stream, session, callback) {
+        server.onData = function (stream, session, callback) {
             let chunks = [];
-            stream.on('data', function(chunk) {
+            stream.on('data', function (chunk) {
                 chunks.push(chunk);
             });
-            stream.on('end', function() {
+            stream.on('end', function () {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n') + '\r\n');
                 callback();
             });
         };
@@ -609,27 +609,27 @@ describe('SMTP Pool Tests', function() {
             );
         }
 
         let total = 100;
         let returned = 0;
-        let cb = function() {
+        let cb = function () {
             if (++returned === total) {
                 pool.close();
                 return done();
             }
         };
 
         let i = 0;
-        pool.on('idle', function() {
-            setTimeout(function() {
+        pool.on('idle', function () {
+            setTimeout(function () {
                 while (i < total && pool.isIdle()) {
                     i++;
                     sendMessage(cb);
                 }
                 if (i > 50) {
                     // kill all connections. We should still end up with the same amount of callbacks
-                    setImmediate(function() {
+                    setImmediate(function () {
                         for (let j = 5 - 1; j >= 0; j--) {
                             if (pool._connections[j] && pool._connections[j].connection) {
                                 pool._connections[j].connection._socket.emit('error', new Error('TESTERROR'));
                             }
                         }
@@ -637,36 +637,36 @@ describe('SMTP Pool Tests', function() {
                 }
             }, 1000);
         });
     });
 
-    it('Should login and send mail using proxied socket', function(done) {
+    it('Should login and send mail using proxied socket', function (done) {
         let pool = new SMTPPool({
             url: 'smtp:testuser:testpass@www.example.com:1234',
             logger: false,
             getSocket(options, callback) {
                 let socket = net.connect(PORT_NUMBER, 'localhost');
-                let errHandler = function(err) {
+                let errHandler = function (err) {
                     callback(err);
                 };
                 socket.on('error', errHandler);
-                socket.on('connect', function() {
+                socket.on('connect', function () {
                     socket.removeListener('error', errHandler);
                     callback(null, {
                         connection: socket
                     });
                 });
             }
         });
         let chunks = [],
             message = new Array(1024).join('teretere, vana kere\n');
 
-        server.on('data', function(connection, chunk) {
+        server.on('data', function (connection, chunk) {
             chunks.push(chunk);
         });
 
-        server.on('dataReady', function(connection, callback) {
+        server.on('dataReady', function (connection, callback) {
             let body = Buffer.concat(chunks);
             expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n') + '\r\n');
             callback(null, true);
         });
 
@@ -679,39 +679,39 @@ describe('SMTP Pool Tests', function() {
                         to: 'test@valid.recipient'
                     },
                     message
                 )
             },
-            function(err) {
+            function (err) {
                 expect(err).to.not.exist;
                 pool.close();
                 return done();
             }
         );
     });
 
-    it('Should verify connection with success', function(done) {
+    it('Should verify connection with success', function (done) {
         let client = new SMTPPool({
             url: 'smtp:testuser:testpass@localhost:' + PORT_NUMBER,
             logger: false
         });
 
-        client.verify(function(err, success) {
+        client.verify(function (err, success) {
             expect(err).to.not.exist;
             expect(success).to.be.true;
             client.close();
             done();
         });
     });
 
-    it('Should not verify connection', function(done) {
+    it('Should not verify connection', function (done) {
         let client = new SMTPPool({
             url: 'smtp:testuser:testpass@localhost:999' + PORT_NUMBER,
             logger: false
         });
 
-        client.verify(function(err) {
+        client.verify(function (err) {
             expect(err).to.exist;
             client.close();
             done();
         });
     });
diff --git a/test/smtp-transport/smtp-tranport-test.js b/test/smtp-transport/smtp-tranport-test.js
index 65c0a39..8df749e 100644
--- a/test/smtp-transport/smtp-tranport-test.js
+++ b/test/smtp-transport/smtp-tranport-test.js
@@ -39,22 +39,22 @@ class MockBuilder {
     getHeader() {
         return 'teretere';
     }
 }
 
-describe('SMTP Transport Tests', function() {
+describe('SMTP Transport Tests', function () {
     this.timeout(10000); // eslint-disable-line no-invalid-this
 
-    describe('Anonymous sender tests', function() {
+    describe('Anonymous sender tests', function () {
         let server, failingServer;
 
-        beforeEach(function(done) {
+        beforeEach(function (done) {
             server = new SMTPServer({
                 disabledCommands: ['STARTTLS', 'AUTH'],
 
                 onData(stream, session, callback) {
-                    stream.on('data', function() {});
+                    stream.on('data', function () {});
                     stream.on('end', callback);
                 },
 
                 onMailFrom(address, session, callback) {
                     if (!/@valid.sender/.test(address.address)) {
@@ -106,31 +106,31 @@ describe('SMTP Transport Tests', function() {
                 }
                 failingServer.listen(PORT_NUMBER + 1, done);
             });
         });
 
-        afterEach(function(done) {
+        afterEach(function (done) {
             server.close(() => failingServer.close(done));
         });
 
-        it('Should expose version number', function() {
+        it('Should expose version number', function () {
             let client = new SMTPTransport();
             expect(client.name).to.exist;
             expect(client.version).to.exist;
         });
 
-        it('Should detect wellknown data', function() {
+        it('Should detect wellknown data', function () {
             let client = new SMTPTransport({
                 service: 'google mail',
                 logger: false
             });
             expect(client.options.host).to.equal('smtp.gmail.com');
             expect(client.options.port).to.equal(465);
             expect(client.options.secure).to.be.true;
         });
 
-        it('Should fail envelope', function(done) {
+        it('Should fail envelope', function (done) {
             let client = new SMTPTransport({
                 port: PORT_NUMBER,
                 logger: false
             });
 
@@ -143,18 +143,18 @@ describe('SMTP Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         'test'
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err.code).to.equal('EENVELOPE');
                     done();
                 }
             );
         });
 
-        it('Should not fail auth', function(done) {
+        it('Should not fail auth', function (done) {
             let client = new SMTPTransport({
                 port: PORT_NUMBER,
                 auth: {
                     user: 'zzz'
                 },
@@ -170,18 +170,18 @@ describe('SMTP Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         'message'
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.not.exist;
                     done();
                 }
             );
         });
 
-        it('Should fail auth if forceAuth=true', function(done) {
+        it('Should fail auth if forceAuth=true', function (done) {
             let client = new SMTPTransport({
                 port: PORT_NUMBER,
                 auth: {
                     user: 'zzz'
                 },
@@ -198,27 +198,27 @@ describe('SMTP Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         'message'
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err.code).to.equal('EAUTH');
                     done();
                 }
             );
         });
 
-        it('Should send mail', function(done) {
+        it('Should send mail', function (done) {
             let client = new SMTPTransport('smtp:localhost:' + PORT_NUMBER + '?logger=false');
             let chunks = [],
                 message = new Array(1024).join('teretere, vana kere\n');
 
-            server.on('data', function(connection, chunk) {
+            server.on('data', function (connection, chunk) {
                 chunks.push(chunk);
             });
 
-            server.on('dataReady', function(connection, callback) {
+            server.on('dataReady', function (connection, callback) {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n'));
                 callback(null, true);
             });
 
@@ -231,27 +231,27 @@ describe('SMTP Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.not.exist;
                     done();
                 }
             );
         });
 
-        it('Should recover unexpeced close during transmission', function(done) {
+        it('Should recover unexpeced close during transmission', function (done) {
             let client = new SMTPTransport('smtp:localhost:' + (PORT_NUMBER + 1) + '?logger=false');
             let chunks = [],
                 message = new Array(1024).join('teretere, vana kere\n');
 
-            server.on('data', function(connection, chunk) {
+            server.on('data', function (connection, chunk) {
                 chunks.push(chunk);
             });
 
-            server.on('dataReady', function(connection, callback) {
+            server.on('dataReady', function (connection, callback) {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n'));
                 callback(null, true);
             });
 
@@ -264,28 +264,28 @@ describe('SMTP Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.exist;
                     done();
                 }
             );
         });
     });
 
-    describe('Authenticated sender tests', function() {
+    describe('Authenticated sender tests', function () {
         let server;
 
-        beforeEach(function(done) {
+        beforeEach(function (done) {
             server = new SMTPServer({
                 authMethods: ['PLAIN', 'XOAUTH2'],
                 disabledCommands: ['STARTTLS'],
 
                 onData(stream, session, callback) {
-                    stream.on('data', function() {});
+                    stream.on('data', function () {});
                     stream.on('end', callback);
                 },
 
                 onAuth(auth, session, callback) {
                     if (auth.method !== 'XOAUTH2') {
@@ -321,27 +321,27 @@ describe('SMTP Transport Tests', function() {
             });
 
             server.listen(PORT_NUMBER, done);
         });
 
-        afterEach(function(done) {
+        afterEach(function (done) {
             server.close(done);
         });
 
-        it('Should login and send mail', function(done) {
+        it('Should login and send mail', function (done) {
             let client = new SMTPTransport({
                 url: 'smtp:testuser:testpass@localhost:' + PORT_NUMBER,
                 logger: false
             });
             let chunks = [],
                 message = new Array(1024).join('teretere, vana kere\n');
 
-            server.on('data', function(connection, chunk) {
+            server.on('data', function (connection, chunk) {
                 chunks.push(chunk);
             });
 
-            server.on('dataReady', function(connection, callback) {
+            server.on('dataReady', function (connection, callback) {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n'));
                 callback(null, true);
             });
 
@@ -354,68 +354,68 @@ describe('SMTP Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.not.exist;
                     done();
                 }
             );
         });
 
-        it('Should verify connection with success', function(done) {
+        it('Should verify connection with success', function (done) {
             let client = new SMTPTransport({
                 url: 'smtp:testuser:testpass@localhost:' + PORT_NUMBER,
                 logger: false
             });
 
-            client.verify(function(err, success) {
+            client.verify(function (err, success) {
                 expect(err).to.not.exist;
                 expect(success).to.be.true;
                 done();
             });
         });
 
-        it('Should not verify connection', function(done) {
+        it('Should not verify connection', function (done) {
             let client = new SMTPTransport({
                 url: 'smtp:testuser:testpass@localhost:999' + PORT_NUMBER,
                 logger: false
             });
 
-            client.verify(function(err) {
+            client.verify(function (err) {
                 expect(err).to.exist;
                 done();
             });
         });
 
-        it('Should login and send mail using proxied socket', function(done) {
+        it('Should login and send mail using proxied socket', function (done) {
             let client = new SMTPTransport({
                 url: 'smtp:testuser:testpass@www.example.com:1234',
                 logger: false,
                 getSocket(options, callback) {
                     let socket = net.connect(PORT_NUMBER, 'localhost');
-                    let errHandler = function(err) {
+                    let errHandler = function (err) {
                         callback(err);
                     };
                     socket.on('error', errHandler);
-                    socket.on('connect', function() {
+                    socket.on('connect', function () {
                         socket.removeListener('error', errHandler);
                         callback(null, {
                             connection: socket
                         });
                     });
                 }
             });
             let chunks = [],
                 message = new Array(1024).join('teretere, vana kere\n');
 
-            server.on('data', function(connection, chunk) {
+            server.on('data', function (connection, chunk) {
                 chunks.push(chunk);
             });
 
-            server.on('dataReady', function(connection, callback) {
+            server.on('dataReady', function (connection, callback) {
                 let body = Buffer.concat(chunks);
                 expect(body.toString()).to.equal(message.trim().replace(/\n/g, '\r\n'));
                 callback(null, true);
             });
 
@@ -428,11 +428,11 @@ describe('SMTP Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err) {
+                function (err) {
                     expect(err).to.not.exist;
                     done();
                 }
             );
         });
diff --git a/test/stream-transport/stream-transport-test.js b/test/stream-transport/stream-transport-test.js
index e1cb741..50a13bb 100644
--- a/test/stream-transport/stream-transport-test.js
+++ b/test/stream-transport/stream-transport-test.js
@@ -33,21 +33,21 @@ class MockBuilder {
     getHeader() {
         return 'teretere';
     }
 }
 
-describe('Stream Transport Tests', function() {
+describe('Stream Transport Tests', function () {
     this.timeout(10000); // eslint-disable-line no-invalid-this
 
-    it('Should expose version number', function() {
+    it('Should expose version number', function () {
         let client = new StreamTransport();
         expect(client.name).to.exist;
         expect(client.version).to.exist;
     });
 
-    describe('Send as stream', function() {
-        it('Should send mail using unix newlines', function(done) {
+    describe('Send as stream', function () {
+        it('Should send mail using unix newlines', function (done) {
             let client = new StreamTransport();
             let chunks = [],
                 message = new Array(100).join('teretere\r\nvana kere\r\n');
 
             client.send(
@@ -59,34 +59,34 @@ describe('Stream Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err, info) {
+                function (err, info) {
                     expect(err).to.not.exist;
 
                     expect(info.envelope).to.deep.equal({
                         from: 'test@valid.sender',
                         to: 'test@valid.recipient'
                     });
 
                     expect(info.messageId).to.equal('<test>');
 
-                    info.message.on('data', function(chunk) {
+                    info.message.on('data', function (chunk) {
                         chunks.push(chunk);
                     });
 
-                    info.message.on('end', function() {
+                    info.message.on('end', function () {
                         let body = Buffer.concat(chunks);
                         expect(body.toString()).to.equal(message.replace(/\r\n/g, '\n'));
                         done();
                     });
                 }
             );
         });
 
-        it('Should send mail using windows newlines', function(done) {
+        it('Should send mail using windows newlines', function (done) {
             let client = new StreamTransport({
                 newline: 'windows'
             });
             let chunks = [],
                 message = new Array(100).join('teretere\nvana kere\n');
@@ -100,29 +100,29 @@ describe('Stream Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err, info) {
+                function (err, info) {
                     expect(err).to.not.exist;
 
-                    info.message.on('data', function(chunk) {
+                    info.message.on('data', function (chunk) {
                         chunks.push(chunk);
                     });
 
-                    info.message.on('end', function() {
+                    info.message.on('end', function () {
                         let body = Buffer.concat(chunks);
                         expect(body.toString()).to.equal(message.replace(/\n/g, '\r\n'));
                         done();
                     });
                 }
             );
         });
     });
 
-    describe('Send as buffer', function() {
-        it('Should send mail using unix newlines', function(done) {
+    describe('Send as buffer', function () {
+        it('Should send mail using unix newlines', function (done) {
             let client = new StreamTransport({
                 buffer: true
             });
             let message = new Array(100).join('teretere\r\nvana kere\r\n');
 
@@ -135,20 +135,20 @@ describe('Stream Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err, info) {
+                function (err, info) {
                     expect(err).to.not.exist;
 
                     expect(info.message.toString()).to.equal(message.replace(/\r\n/g, '\n'));
                     done();
                 }
             );
         });
 
-        it('Should send mail using windows newlines', function(done) {
+        it('Should send mail using windows newlines', function (done) {
             let client = new StreamTransport({
                 newline: 'windows',
                 buffer: true
             });
             let message = new Array(100).join('teretere\nvana kere\n');
@@ -162,11 +162,11 @@ describe('Stream Transport Tests', function() {
                             to: 'test@valid.recipient'
                         },
                         message
                     )
                 },
-                function(err, info) {
+                function (err, info) {
                     expect(err).to.not.exist;
 
                     expect(info.message.toString()).to.equal(message.replace(/\n/g, '\r\n'));
                     done();
                 }
diff --git a/test/well-known/well-known-test.js b/test/well-known/well-known-test.js
index ac171de..0bad222 100644
--- a/test/well-known/well-known-test.js
+++ b/test/well-known/well-known-test.js
@@ -7,36 +7,36 @@ const chai = require('chai');
 const expect = chai.expect;
 const wellKnown = require('../../lib/well-known');
 
 chai.config.includeStack = true;
 
-describe('Well-Known Services Tests', function() {
-    describe('#wellKnown', function() {
-        it('Should find by key', function() {
+describe('Well-Known Services Tests', function () {
+    describe('#wellKnown', function () {
+        it('Should find by key', function () {
             expect(wellKnown('Gmail')).to.deep.equal({
                 host: 'smtp.gmail.com',
                 port: 465,
                 secure: true
             });
         });
 
-        it('Should find by alias', function() {
+        it('Should find by alias', function () {
             expect(wellKnown('Google Mail')).to.deep.equal({
                 host: 'smtp.gmail.com',
                 port: 465,
                 secure: true
             });
         });
 
-        it('Should find by domain', function() {
+        it('Should find by domain', function () {
             expect(wellKnown('GoogleMail.com')).to.deep.equal({
                 host: 'smtp.gmail.com',
                 port: 465,
                 secure: true
             });
         });
 
-        it('Should find no match', function() {
+        it('Should find no match', function () {
             expect(wellKnown('zzzzzz')).to.be.false;
         });
     });
 });
diff --git a/test/xoauth2/server.js b/test/xoauth2/server.js
index 8301843..8f37401 100644
--- a/test/xoauth2/server.js
+++ b/test/xoauth2/server.js
@@ -4,11 +4,11 @@
 
 const http = require('http');
 const crypto = require('crypto');
 const querystring = require('querystring');
 
-module.exports = function(options) {
+module.exports = function (options) {
     return new OAuthServer(options);
 };
 
 function OAuthServer(options) {
     this.options = options || {};
@@ -17,11 +17,11 @@ function OAuthServer(options) {
 
     this.options.port = Number(this.options.port) || 3080;
     this.options.expiresIn = Number(this.options.expiresIn) || 3600;
 }
 
-OAuthServer.prototype.addUser = function(username, refreshToken) {
+OAuthServer.prototype.addUser = function (username, refreshToken) {
     let user = {
         username,
         refreshToken: refreshToken || crypto.randomBytes(10).toString('base64')
     };
 
@@ -29,11 +29,11 @@ OAuthServer.prototype.addUser = function(username, refreshToken) {
     this.tokens[user.refreshToken] = username;
 
     return this.generateAccessToken(user.refreshToken);
 };
 
-OAuthServer.prototype.generateAccessToken = function(refreshToken) {
+OAuthServer.prototype.generateAccessToken = function (refreshToken) {
     let username = this.tokens[refreshToken];
     let accessToken = crypto.randomBytes(10).toString('base64');
 
     if (!username) {
         return {
@@ -53,19 +53,19 @@ OAuthServer.prototype.generateAccessToken = function(refreshToken) {
         expires_in: this.options.expiresIn,
         token_type: 'Bearer'
     };
 };
 
-OAuthServer.prototype.validateAccessToken = function(username, accessToken) {
+OAuthServer.prototype.validateAccessToken = function (username, accessToken) {
     if (!this.users[username] || this.users[username].accessToken !== accessToken || this.users[username].expiresIn < Date.now()) {
         return false;
     } else {
         return true;
     }
 };
 
-OAuthServer.prototype.start = function(callback) {
+OAuthServer.prototype.start = function (callback) {
     this.server = http.createServer((req, res) => {
         let data = [];
         let datalen = 0;
 
         req.on('data', chunk => {
@@ -90,8 +90,8 @@ OAuthServer.prototype.start = function(callback) {
     });
 
     this.server.listen(this.options.port, callback);
 };
 
-OAuthServer.prototype.stop = function(callback) {
+OAuthServer.prototype.stop = function (callback) {
     this.server.close(callback);
 };
diff --git a/test/xoauth2/xoauth2-test.js b/test/xoauth2/xoauth2-test.js
index 3e6d953..90fe565 100644
--- a/test/xoauth2/xoauth2-test.js
+++ b/test/xoauth2/xoauth2-test.js
@@ -8,95 +8,95 @@ const expect = chai.expect;
 const XOAuth2 = require('../../lib/xoauth2');
 const mockServer = require('./server');
 
 chai.config.includeStack = true;
 
-describe('XOAuth2 tests', function() {
+describe('XOAuth2 tests', function () {
     this.timeout(10000);
 
     let server;
     let users = {};
     let XOAUTH_PORT = 8993;
 
-    beforeEach(function(done) {
+    beforeEach(function (done) {
         server = mockServer({
             port: XOAUTH_PORT,
-            onUpdate: function(username, accessToken) {
+            onUpdate: function (username, accessToken) {
                 users[username] = accessToken;
             }
         });
         server.addUser('test@example.com', 'saladus');
         server.start(done);
     });
 
-    afterEach(function(done) {
+    afterEach(function (done) {
         server.stop(done);
     });
 
-    it('should get an existing access token', function(done) {
+    it('should get an existing access token', function (done) {
         let xoauth2 = new XOAuth2({
             user: 'test@example.com',
             clientId: '{Client ID}',
             clientSecret: '{Client Secret}',
             refreshToken: 'saladus',
             accessUrl: 'http://localhost:' + XOAUTH_PORT + '/',
             accessToken: 'abc',
             timeout: 3600
         });
 
-        xoauth2.getToken(false, function(err, accessToken) {
+        xoauth2.getToken(false, function (err, accessToken) {
             expect(err).to.not.exist;
             expect(accessToken).to.equal('abc');
             done();
         });
     });
 
-    it('should convert access token to XOAuth2 token', function() {
+    it('should convert access token to XOAuth2 token', function () {
         let xoauth2 = new XOAuth2({
             user: 'test@example.com',
             accessToken: 'abc'
         });
 
         expect(xoauth2.buildXOAuth2Token()).to.equal('dXNlcj10ZXN0QGV4YW1wbGUuY29tAWF1dGg9QmVhcmVyIGFiYwEB');
         expect(xoauth2.buildXOAuth2Token('bbb')).to.equal('dXNlcj10ZXN0QGV4YW1wbGUuY29tAWF1dGg9QmVhcmVyIGJiYgEB');
     });
 
-    it('should get an existing access token, no timeout', function(done) {
+    it('should get an existing access token, no timeout', function (done) {
         let xoauth2 = new XOAuth2({
             user: 'test@example.com',
             clientId: '{Client ID}',
             clientSecret: '{Client Secret}',
             refreshToken: 'saladus',
             accessUrl: 'http://localhost:' + XOAUTH_PORT + '/',
             accessToken: 'abc'
         });
 
-        xoauth2.getToken(false, function(err, accessToken) {
+        xoauth2.getToken(false, function (err, accessToken) {
             expect(err).to.not.exist;
             expect(accessToken).to.equal('abc');
             done();
         });
     });
 
-    it('should generate a fresh access token', function(done) {
+    it('should generate a fresh access token', function (done) {
         let xoauth2 = new XOAuth2({
             user: 'test@example.com',
             clientId: '{Client ID}',
             clientSecret: '{Client Secret}',
             refreshToken: 'saladus',
             accessUrl: 'http://localhost:' + XOAUTH_PORT + '/',
             timeout: 3600
         });
 
-        xoauth2.getToken(false, function(err, accessToken) {
+        xoauth2.getToken(false, function (err, accessToken) {
             expect(err).to.not.exist;
             expect(accessToken).to.equal(users['test@example.com']);
             done();
         });
     });
 
-    it('should generate a fresh access token with custom method', function(done) {
+    it('should generate a fresh access token with custom method', function (done) {
         let xoauth2 = new XOAuth2({
             user: 'test@example.com',
             clientId: '{Client ID}',
             clientSecret: '{Client Secret}',
             refreshToken: 'saladus',
@@ -105,18 +105,18 @@ describe('XOAuth2 tests', function() {
             provisionCallback: (user, renew, cb) => {
                 cb(null, 'zzz');
             }
         });
 
-        xoauth2.getToken(false, function(err, accessToken) {
+        xoauth2.getToken(false, function (err, accessToken) {
             expect(err).to.not.exist;
             expect(accessToken).to.equal('zzz');
             done();
         });
     });
 
-    it('should fail generating a fresh access token with custom method', function(done) {
+    it('should fail generating a fresh access token with custom method', function (done) {
         let xoauth2 = new XOAuth2({
             user: 'test@example.com',
             clientId: '{Client ID}',
             clientSecret: '{Client Secret}',
             refreshToken: 'saladus',
@@ -125,61 +125,61 @@ describe('XOAuth2 tests', function() {
             provisionCallback: (user, renew, cb) => {
                 cb(new Error('fail'));
             }
         });
 
-        xoauth2.getToken(false, function(err, accessToken) {
+        xoauth2.getToken(false, function (err, accessToken) {
             expect(err).to.exist;
             expect(accessToken).to.not.exist;
             done();
         });
     });
 
-    it('should generate a fresh access token after timeout', function(done) {
+    it('should generate a fresh access token after timeout', function (done) {
         let xoauth2 = new XOAuth2({
             user: 'test@example.com',
             clientId: '{Client ID}',
             clientSecret: '{Client Secret}',
             refreshToken: 'saladus',
             accessUrl: 'http://localhost:' + XOAUTH_PORT + '/',
             accessToken: 'abc',
             timeout: 1
         });
 
-        setTimeout(function() {
-            xoauth2.getToken(false, function(err, accessToken) {
+        setTimeout(function () {
+            xoauth2.getToken(false, function (err, accessToken) {
                 expect(err).to.not.exist;
                 expect(accessToken).to.equal(users['test@example.com']);
                 done();
             });
         }, 3000);
     });
 
-    it('should emit access token update', function(done) {
+    it('should emit access token update', function (done) {
         let xoauth2 = new XOAuth2({
             user: 'test@example.com',
             clientId: '{Client ID}',
             clientSecret: '{Client Secret}',
             refreshToken: 'saladus',
             accessUrl: 'http://localhost:' + XOAUTH_PORT + '/',
             timeout: 3600
         });
 
-        xoauth2.once('token', function(tokenData) {
+        xoauth2.once('token', function (tokenData) {
             expect(tokenData.expires).to.be.gte(Date.now() + 3000 * 1000);
             expect(tokenData).to.deep.equal({
                 user: 'test@example.com',
                 accessToken: users['test@example.com'],
                 expires: tokenData.expires
             });
             done();
         });
 
-        xoauth2.getToken(false, function() {});
+        xoauth2.getToken(false, function () {});
     });
 
-    it('should sign payload', function() {
+    it('should sign payload', function () {
         let xoauth2 = new XOAuth2({
             user: 'test@example.com',
             serviceClient: '{Client ID}',
             accessUrl: 'http://localhost:' + XOAUTH_PORT + '/',
             timeout: 3600,

Vulnerable code: module.exports = function(grunt) {
                key: line
                    .substr(0, line.indexOf(':'))
                    .trim()
                    .toLowerCase(),
                let key = valueParts
                    .shift()
                    .trim()
                    .toLowerCase();
module.exports = function(url, options) {
    let method =
        (options.method || '')
            .toString()
            .trim()
            .toUpperCase() || 'GET';
        method =
            (options.method || '')
                .toString()
                .trim()
                .toUpperCase() || 'POST';
                    attachment.filename =
                        (attachment.path || attachment.href || '')
                            .split('/')
                            .pop()
                            .split('?')
                            .shift() || 'attachment-' + (i + 1);
        let extension = (parsed.ext.substr(1) || parsed.name || '')
            .split('?')
            .shift()
            .trim()
            .toLowerCase();
        let parts = (mimeType || '')
            .toLowerCase()
            .trim()
            .split('/');
const ETHEREAL_CACHE = ['true', 'yes', 'y', '1'].includes(
    (process.env.ETHEREAL_CACHE || 'yes')
        .toString()
        .trim()
        .toLowerCase()
);
module.exports.createTransport = function(transporter, defaults) {
module.exports.createTestAccount = function(apiUrl, callback) {
module.exports.getTestMessageUrl = function(info) {
    function() {
module.exports.assign = function(/* target, ... sources */) {
            console.log(
                '[%s] %s %s',
                new Date()
                    .toISOString()
                    .substr(0, 19)
                    .replace(/T/, ' '),
                levelNames.get(level),
                prefix + line
            );
    let tempSocketErr = function(err) {
        this.id = crypto
            .randomBytes(8)
            .toString('base64')
            .replace(/\W/g, '');
            let mapKey = (key || '')
                .toString()
                .trim()
                .toUpperCase();
        this._authMethod =
            (this._auth.method || '')
                .toString()
                .trim()
                .toUpperCase() || false;
        let callback = function() {
module.exports = function(key) {
    
        "host": "smtp.ethereal.email",   
                if(data.error_description) {
                  errorMessage += ': ' + data.error_description;
                if(data.error_uri) {
                  errorMessage += ' (' + data.error_uri + ')';
    "version": "6.4.15",
describe('Base64 Tests', function() {
    describe('#encode', function() {
        it('shoud encode UTF-8 string to base64', function() {
            encodeFixtures.forEach(function(test) {
        it('shoud encode Buffer to base64', function() {
    describe('#wrap', function() {
        it('should wrap long base64 encoded lines', function() {
            wrapFixtures.forEach(function(test) {
    describe('base64 Streams', function() {
        it('should transform incoming bytes to base64', function(done) {
            encoder.on('data', function(chunk) {
            encoder.on('end', function(chunk) {
            let sendNextByte = function() {
        it('should transform incoming bytes to base64 and back', function(done) {
            file.on('data', function(chunk) {
            file.on('end', function() {
            decoder.on('data', function(chunk) {
            decoder.on('end', function() {
describe('DKIM Tests', function() {
    it('should sign message', function(done) {
    it('should sign large message using cache dir', function(done) {
    it('should sign large message without cache dir', function(done) {
    it('should emit cache error', function(done) {
    it('should sign large message as Buffer', function(done) {
    it('should sign large message as String', function(done) {
describe('DKIM MessageParser Tests', function() {
    it('should extract header and body', function(done) {
describe('DKIM RelaxedBody Tests', function() {
    it('Should calculate body hash byte by byte', function(done) {
    it('Should calculate body hash all at once', function(done) {
describe('DKIM Sign Tests', function() {
    it('should create relaxed headers', function() {
    it('should skip specific headers', function() {
    it('should sign headers', function() {
    it('should sign headers for unicode domain', function() {
describe('Ethereal Tests', function() {
    it('should create an account and send a message', function(done) {
    it('should cache a created test account', function(done) {
    it('should cache a created test account when using promises', function(done) {
describe('Cookie Tests', function() {
    beforeEach(function() {
    describe('#getPath', function() {
        it('should return root path', function() {
        it('should return without file', function() {
    describe('#isExpired', function() {
        it('should match expired cookie', function() {
    describe('#compare', function() {
        it('should match similar cookies', function() {
    describe('#add', function() {
        it('should append new cookie', function() {
        it('should update existing cookie', function() {
    describe('#match', function() {
        it('should check if a cookie matches particular domain and path', function() {
        it('should check if a cookie matches particular domain and path', function() {
        it('should check if a cookie is secure', function() {
    describe('#parse', function() {
        it('should parse Set-Cookie value', function() {
        it('should ignore invalid expire header', function() {
    describe('Listing', function() {
        beforeEach(function() {
        describe('#list', function() {
            it('should return matching cookies for an URL', function() {
        describe('#get', function() {
            it('should return matching cookies for an URL', function() {
    describe('#set', function() {
        it('should set cookie', function() {
                biskviit.cookies.map(function(cookie) {
describe('Fetch Tests', function() {
    beforeEach(function(done) {
        httpServer = http.createServer(function(req, res) {
                    req.on('readable', function() {
                    req.on('end', function() {
        httpsServer = https.createServer(httpsOptions, function(req, res) {
        httpServer.listen(HTTP_PORT, function() {
    afterEach(function(done) {
        httpServer.close(function() {
    it('should fetch HTTP data', function(done) {
        req.on('data', function(chunk) {
        req.on('end', function() {
    it('should fetch HTTPS data', function(done) {
        req.on('data', function(chunk) {
        req.on('end', function() {
    it('should fetch HTTP data with redirects', function(done) {
        req.on('data', function(chunk) {
        req.on('end', function() {
    it('should return error for too many redirects', function(done) {
        req.on('data', function(chunk) {
        req.on('error', function(err) {
        req.on('end', function() {});
    it('should fetch HTTP data with custom redirect limit', function(done) {
        req.on('data', function(chunk) {
        req.on('end', function() {
    it('should return error for custom redirect limit', function(done) {
        req.on('data', function(chunk) {
        req.on('error', function(err) {
        req.on('end', function() {});
    it('should return disable redirects', function(done) {
        req.on('data', function(chunk) {
        req.on('error', function(err) {
        req.on('end', function() {});
    it('should unzip compressed HTTP data', function(done) {
        req.on('data', function(chunk) {
        req.on('end', function() {
    it('should return error for unresolved host', function(done) {
        req.on('data', function(chunk) {
        req.on('error', function(err) {
        req.on('end', function() {});
    it('should return error for invalid status', function(done) {
        req.on('data', function(chunk) {
        req.on('error', function(err) {
        req.on('end', function() {});
    it('should allow invalid status', function(done) {
        req.on('data', function(chunk) {
        req.on('error', function(err) {
        req.on('end', function() {
    it('should return error for invalid url', function(done) {
        req.on('data', function(chunk) {
        req.on('error', function(err) {
        req.on('end', function() {});
    it('should return timeout error', function(done) {
        req.on('data', function(chunk) {
        req.on('error', function(err) {
        req.on('end', function() {});
    it('should handle basic HTTP auth', function(done) {
        req.on('data', function(chunk) {
        req.on('end', function() {
        it('should return error for invalid protocol', function(done) {
            req.on('data', function(chunk) {
            req.on('error', function(err) {
            req.on('end', function() {});
    it('should set cookie value', function(done) {
        req.on('data', function(chunk) {
        req.on('end', function() {
    it('should set user agent', function(done) {
        req.on('data', function(chunk) {
        req.on('end', function() {
    it('should post data', function(done) {
        req.on('data', function(chunk) {
        req.on('end', function() {
    it('should post stream data', function(done) {
        req.on('data', function(chunk) {
        req.on('end', function() {
        let writeNext = function() {
    it('should return error for invalid cert', function(done) {
        req.on('data', function(chunk) {
        req.on('error', function(err) {
        req.on('end', function() {});
describe('JSON Transport Tests', function() {
    it('should return an JSON string', function(done) {
    it('should return an JSON string for calendar event', function(done) {
describe('Quoted-Printable Tests', function() {
    describe('#encode', function() {
        it('shoud encode UTF-8 string to QP', function() {
            encodeFixtures.forEach(function(test) {
        it('shoud encode Buffer to QP', function() {
    describe('#wrap', function() {
        it('should wrap long QP encoded lines', function() {
            wrapFixtures.forEach(function(test) {
        it('should wrap line ending with <CR>', function() {
    describe('QP Streams', function() {
        it('should transform incoming bytes to QP', function(done) {
            encoder.on('data', function(chunk) {
            encoder.on('end', function(chunk) {
            let sendNextByte = function() {
        it('should transform incoming bytes to QP and back', function(done) {
            file.on('data', function(chunk) {
            file.on('end', function() {
            decoder.on('data', function(chunk) {
            decoder.on('end', function() {
describe('Sendmail Unix Newlines', function() {
    it('should rewrite all linebreaks (byte by byte)', function(done) {
    it('should rewrite all linebreaks (all at once)', function(done) {
describe('Sendmail Windows Newlines', function() {
    it('should rewrite all linebreaks (byte by byte)', function(done) {
    it('should rewrite all linebreaks (all at once)', function(done) {
describe('Sendmail Transport Tests', function() {
    it('Should expose version number', function() {
    it('Should send message', function(done) {
        stubbedSpawn.stdin.on('data', function(chunk) {
        stubbedSpawn.stdin.on('end', function() {
            function(err, data) {
    it('Should return an error', function(done) {
        stubbedSpawn.stdin.on('end', function() {
            function(err, data) {
describe('SES Transport Tests', function() {
    it('should return MessageId', function(done) {
    it('should sign message with DKIM', function(done) {
    it('should limit parallel connections', function(done) {
    it('should rate limit messages', function(done) {
    it('should rate limit long messages', function(done) {
    it('should rate limit messages and connections', function(done) {
    it('detect sending slots on idle events', function(done) {
describe('Shared Funcs Tests', function() {
    describe('Logger tests', function() {
        it('Should create a logger', function() {
    describe('Connection url parser tests', function() {
        it('Should parse connection url', function() {
        it('should not choke on special symbols in auth', function() {
    describe('Resolver tests', function() {
        beforeEach(function(done) {
            server = http.createServer(function(req, res) {
        afterEach(function(done) {
        it('should set text from html string', function(done) {
            shared.resolveContent(mail.data, 'html', function(err, value) {
        it('should set text from html buffer', function(done) {
            shared.resolveContent(mail.data, 'html', function(err, value) {
        it('should set text from a html file', function(done) {
            shared.resolveContent(mail.data, 'html', function(err, value) {
        it('should set text from an html url', function(done) {
            shared.resolveContent(mail.data, 'html', function(err, value) {
        it('should set text from redirecting url', function(done) {
            shared.resolveContent(mail.data, 'html', function(err, value) {
        it('should set text from gzipped url', function(done) {
            shared.resolveContent(mail.data, 'html', function(err, value) {
        it('should set text from a html stream', function(done) {
            shared.resolveContent(mail.data, 'html', function(err, value) {
        it('should return an error', function(done) {
            shared.resolveContent(mail.data, 'html', function(err) {
        it('should return encoded string as buffer', function(done) {
            shared.resolveContent(mail.data, 'html', function(err, value) {
        describe('data uri tests', function() {
            it('should resolve with mime type and base64', function(done) {
                shared.resolveContent(mail.data, 'attachment', function(err, value) {
            it('should resolve with mime type and plaintext', function(done) {
                shared.resolveContent(mail.data, 'attachment', function(err, value) {
            it('should resolve with plaintext', function(done) {
                shared.resolveContent(mail.data, 'attachment', function(err, value) {
            it('should resolve with mime type, charset and base64', function(done) {
                shared.resolveContent(mail.data, 'attachment', function(err, value) {
    describe('#assign tests', function() {
        it('should assign multiple objects to target', function() {
    describe('#encodeXText tests', function() {
        it('should not encode atom', function() {
        it('should not encode email', function() {
        it('should encode space', function() {
        it('should encode unicode', function() {
        it('should encode low codes', function() {
describe('HTTP Proxy Client Tests', function() {
    it('should connect to a socket through proxy', function(done) {
    it('should connect to a socket through proxy with auth', function(done) {
    it('should should fail auth', function(done) {
describe('SMTP-Connection Tests', function() {
    describe('Version test', function() {
        it('Should expose version number', function() {
    describe('Connection tests', function() {
        beforeEach(function(done) {
                onAuth: function(auth, session, callback) {
                onData: function(stream, session, callback) {
                    stream.on('data', function() {});
                onData: function(stream, session, callback) {
                    stream.on('data', function(chunk) {
                    stream.on('end', function() {
            invalidServer = net.createServer(function() {});
                onAuth: function(auth, session, callback) {
                onData: function(stream, session, callback) {
                    stream.on('data', function() {});
            server.listen(PORT_NUMBER, function() {
                invalidServer.listen(PORT_NUMBER + 1, function() {
                    secureServer.listen(PORT_NUMBER + 2, function() {
                        insecureServer.listen(PORT_NUMBER + 3, function() {
        afterEach(function(done) {
            server.close(function() {
                invalidServer.close(function() {
                    secureServer.close(function() {
                        insecureServer.close(function() {
        it('should connect to unsecure server', function(done) {
            client.connect(function() {
            client.on('error', function(err) {
        it('should connect to a server and upgrade with STARTTLS', function(done) {
            client.connect(function() {
            client.on('error', function(err) {
        it('should connect to a server and upgrade with forced STARTTLS', function(done) {
            client.connect(function() {
            client.on('error', function(err) {
        it('should connect to a server and try to upgrade STARTTLS', function(done) {
            client.connect(function() {
            client.on('error', function(err) {
        it('should try upgrade with STARTTLS where not advertised', function(done) {
            client.connect(function() {
            client.once('error', function(err) {
        it('should close connection after STARTTLS', function(done) {
            client.connect(function() {
                server.connections.forEach(function(conn) {
            client.on('error', function(err) {
        it('should connect to a secure server', function(done) {
            client.connect(function() {
            client.on('error', function(err) {
        it('should emit error for invalid port', function(done) {
            client.connect(function() {
            client.once('error', function(err) {
        it('should emit error for too large port', function(done) {
            client.connect(function() {
            client.once('error', function(err) {
        it('should emit inactivity timeout error', function(done) {
            client.connect(function() {
            client.once('error', function(err) {
        it('should connect through proxy', function(done) {
            let runTest = function(socket) {
                client.connect(function() {
                        function(err) {
                client.on('error', function(err) {
            proxyConnect(PROXY_PORT_NUMBER, '127.0.0.1', PORT_NUMBER, '127.0.0.1', function(err, socket) {
        it('should connect through proxy to secure server', function(done) {
            let runTest = function(socket) {
                client.connect(function() {
                        function(err) {
                client.on('error', function(err) {
            proxyConnect(PROXY_PORT_NUMBER, '127.0.0.1', PORT_NUMBER + 2, '127.0.0.1', function(err, socket) {
        it('should send to unsecure server', function(done) {
            client.on('error', function(err) {
            client.connect(function() {
                server.on('data', function(connection, chunk) {
                server.on('dataReady', function(connection, callback) {
                    expect(body.toString()).to.equal(
                        message
                            .toString()
                            .trim()
                            .replace(/\n/g, '\r\n')
                    );
                    function(err) {
    describe('Login tests', function() {
        beforeEach(function(done) {
                onData: function(stream, session, callback) {
                    stream.on('data', function(chunk) {
                    stream.on('end', function() {
                onAuth: function(auth, session, callback) {
                onMailFrom: function(address, session, callback) {
                onRcptTo: function(address, session, callback) {
                onData: function(stream, session, callback) {
                    stream.on('data', function() {});
                    stream.on('end', function() {
                        let response = session.envelope.rcptTo.map(function(rcpt, i) {
                onMailFrom: function(address, session, callback) {
                onRcptTo: function(address, session, callback) {
            server.listen(PORT_NUMBER, function() {
                lmtpServer.listen(LMTP_PORT_NUMBER, function() {
                    client.connect(function() {
        afterEach(function(done) {
            server.close(function() {
        it('should login', function(done) {
                function(err) {
        it('should return error for invalid login', function(done) {
                function(err) {
        it('should return error for missing credentials', function(done) {
                function(err) {
        it('should return error for incomplete credentials', function(done) {
                function(err) {
        describe('xoauth2 login', function() {
            beforeEach(function(done) {
                    onUpdate: function(username, accessToken) {
            afterEach(function(done) {
            it('should login with xoauth2 string', function(done) {
                    function(err) {
            it('should return error for invalid xoauth2 string token', function(done) {
                    function(err) {
            it('should login with xoauth2 object', function(done) {
                    function(err) {
            it('should fail with xoauth2 object', function(done) {
                    function(err) {
            it('should fail with invalid xoauth2 response', function(done) {
                    function(err) {
        describe('custom login', function() {
            beforeEach(function(done) {
            afterEach(function(done) {
            it('should login', function(done) {
                    function(err) {
        describe('Send without PIPELINING', function() {
            beforeEach(function(done) {
                client.on('end', function() {
                    client.connect(function() {
                            function(err) {
            it('should send only to valid recipients without PIPELINING', function(done) {
                    function(err, info) {
        describe('Send messages', function() {
            beforeEach(function(done) {
                    function(err) {
            it('should send message', function(done) {
                    function(err, info) {
            it('should send multiple messages', function(done) {
                    function(err, info) {
                        client.reset(function(err) {
                                function(err, info) {
            it('should send only to valid recipients', function(done) {
                    function(err, info) {
            it('should reject all recipients', function(done) {
                    function(err, info) {
            it('should reject too large SIZE arguments', function(done) {
                    function(err, info) {
            it('should reject too large message', function(done) {
                    function(err, info) {
            it('should declare SIZE', function(done) {
                    function(err, info) {
            it('lmtp should send only to valid recipients', function(done) {
                    function(err, info) {
            it('should send using SMTPUTF8', function(done) {
                    function(err, info) {
            it('should send using 8BITMIME', function(done) {
                    function(err, info) {
            it('should receive error for 8-bit content without 8BITMIME declaration', function(done) {
                    function(err) {
            it('should return error for invalidly formatted recipients', function(done) {
                    function(err) {
            it('should return error for no valid recipients', function(done) {
                    function(err) {
            it('should return error for invalid sender', function(done) {
                    function(err) {
            it('should send message string', function(done) {
                server.on('data', function(connection, chunk) {
                server.on('dataReady', function(connection, callback) {
                    function(err) {
            it('should send message buffer', function(done) {
                server.on('data', function(connection, chunk) {
                server.on('dataReady', function(connection, callback) {
                    expect(body.toString()).to.equal(
                        message
                            .toString()
                            .trim()
                            .replace(/\n/g, '\r\n')
                    );
                    function(err) {
            it('should send message stream', function(done) {
                server.on('data', function(connection, chunk) {
                server.on('dataReady', function(connection, callback) {
                    expect(body.toString()).to.equal(
                        message
                            .toString()
                            .trim()
                            .replace(/\n/g, '\r\n')
                    );
                    function(err) {
    let socket = net.connect(port, host, function() {
        let onSocketData = function(chunk) {
    socket.on('error', function(err) {
module.exports = function(options) {
OAuthServer.prototype.addUser = function(username, refreshToken) {
OAuthServer.prototype.generateAccessToken = function(refreshToken) {
OAuthServer.prototype.validateAccessToken = function(username, accessToken) {
OAuthServer.prototype.start = function(callback) {
OAuthServer.prototype.stop = function(callback) {
describe('SMTP Pool Tests', function() {
    beforeEach(function(done) {
                stream.on('data', function() {});
    afterEach(function(done) {
    it('Should expose version number', function() {
    it('Should detect wellknown data', function() {
    it('should send mail', function(done) {
        server.onData = function(stream, session, callback) {
            stream.on('data', function(chunk) {
            stream.on('end', function() {
            function(err) {
    it('should send multiple mails', function(done) {
        server.onData = function(stream, session, callback) {
            stream.on('data', function(chunk) {
            stream.on('end', function() {
                function(err) {
        let cb = function() {
                pool._connections.forEach(function(conn) {
    it('should tolerate connection errors', function(done) {
        server.onData = function(stream, session, callback) {
            stream.on('data', function(chunk) {
            stream.on('end', function() {
                function(err) {
        let cb = function() {
    it('should tolerate idle connections and re-assign messages to other connections', function(done) {
        server.onData = function(stream, session, callback) {
            stream.on('data', function() {
                    server.connections.forEach(function(connection) {
            stream.on('end', function() {
                function(err) {
        let cb = function() {
    it('should call back with connection errors to senders having messages in flight', function(done) {
            function(err) {
            function(err) {
    it('should not send more then allowed for one connection', function(done) {
        server.onData = function(stream, session, callback) {
            stream.on('data', function(chunk) {
            stream.on('end', function() {
                function(err) {
        let cb = function() {
    it('should send multiple mails with rate limit', function(done) {
        server.onData = function(stream, session, callback) {
            stream.on('data', function(chunk) {
            stream.on('end', function() {
                function(err) {
        let cb = function() {
        let send = function() {
    it('should return pending messages once closed', function(done) {
        server.onData = function(stream, session, callback) {
            stream.on('data', function(chunk) {
            stream.on('end', function() {
                function(err) {
        let cb = function() {
    it('should emit idle for free slots in the pool', function(done) {
        server.onData = function(stream, session, callback) {
            stream.on('data', function(chunk) {
            stream.on('end', function() {
        let cb = function() {
        pool.on('idle', function() {
            setTimeout(function() {
                    setImmediate(function() {
    it('Should login and send mail using proxied socket', function(done) {
                let errHandler = function(err) {
                socket.on('connect', function() {
        server.on('data', function(connection, chunk) {
        server.on('dataReady', function(connection, callback) {
            function(err) {
    it('Should verify connection with success', function(done) {
        client.verify(function(err, success) {
    it('Should not verify connection', function(done) {
        client.verify(function(err) {
describe('SMTP Transport Tests', function() {
    describe('Anonymous sender tests', function() {
        beforeEach(function(done) {
                    stream.on('data', function() {});
        afterEach(function(done) {
        it('Should expose version number', function() {
        it('Should detect wellknown data', function() {
        it('Should fail envelope', function(done) {
                function(err) {
        it('Should not fail auth', function(done) {
                function(err) {
        it('Should fail auth if forceAuth=true', function(done) {
                function(err) {
        it('Should send mail', function(done) {
            server.on('data', function(connection, chunk) {
            server.on('dataReady', function(connection, callback) {
                function(err) {
        it('Should recover unexpeced close during transmission', function(done) {
            server.on('data', function(connection, chunk) {
            server.on('dataReady', function(connection, callback) {
                function(err) {
    describe('Authenticated sender tests', function() {
        beforeEach(function(done) {
                    stream.on('data', function() {});
        afterEach(function(done) {
        it('Should login and send mail', function(done) {
            server.on('data', function(connection, chunk) {
            server.on('dataReady', function(connection, callback) {
                function(err) {
        it('Should verify connection with success', function(done) {
            client.verify(function(err, success) {
        it('Should not verify connection', function(done) {
            client.verify(function(err) {
        it('Should login and send mail using proxied socket', function(done) {
                    let errHandler = function(err) {
                    socket.on('connect', function() {
            server.on('data', function(connection, chunk) {
            server.on('dataReady', function(connection, callback) {
                function(err) {
describe('Stream Transport Tests', function() {
    it('Should expose version number', function() {
    describe('Send as stream', function() {
        it('Should send mail using unix newlines', function(done) {
                function(err, info) {
                    info.message.on('data', function(chunk) {
                    info.message.on('end', function() {
        it('Should send mail using windows newlines', function(done) {
                function(err, info) {
                    info.message.on('data', function(chunk) {
                    info.message.on('end', function() {
    describe('Send as buffer', function() {
        it('Should send mail using unix newlines', function(done) {
                function(err, info) {
        it('Should send mail using windows newlines', function(done) {
                function(err, info) {
describe('Well-Known Services Tests', function() {
    describe('#wellKnown', function() {
        it('Should find by key', function() {
        it('Should find by alias', function() {
        it('Should find by domain', function() {
        it('Should find no match', function() {
module.exports = function(options) {
OAuthServer.prototype.addUser = function(username, refreshToken) {
OAuthServer.prototype.generateAccessToken = function(refreshToken) {
OAuthServer.prototype.validateAccessToken = function(username, accessToken) {
OAuthServer.prototype.start = function(callback) {
OAuthServer.prototype.stop = function(callback) {
describe('XOAuth2 tests', function() {
    beforeEach(function(done) {
            onUpdate: function(username, accessToken) {
    afterEach(function(done) {
    it('should get an existing access token', function(done) {
        xoauth2.getToken(false, function(err, accessToken) {
    it('should convert access token to XOAuth2 token', function() {
    it('should get an existing access token, no timeout', function(done) {
        xoauth2.getToken(false, function(err, accessToken) {
    it('should generate a fresh access token', function(done) {
        xoauth2.getToken(false, function(err, accessToken) {
    it('should generate a fresh access token with custom method', function(done) {
        xoauth2.getToken(false, function(err, accessToken) {
    it('should fail generating a fresh access token with custom method', function(done) {
        xoauth2.getToken(false, function(err, accessToken) {
    it('should generate a fresh access token after timeout', function(done) {
        setTimeout(function() {
            xoauth2.getToken(false, function(err, accessToken) {
    it('should emit access token update', function(done) {
        xoauth2.once('token', function(tokenData) {
        xoauth2.getToken(false, function() {});
    it('should sign payload', function() {
Fixed code:     - 15
module.exports = function (grunt) {
                key: line.substr(0, line.indexOf(':')).trim().toLowerCase(),
                let key = valueParts.shift().trim().toLowerCase();
module.exports = function (url, options) {
    let method = (options.method || '').toString().trim().toUpperCase() || 'GET';
        method = (options.method || '').toString().trim().toUpperCase() || 'POST';
                    attachment.filename = (attachment.path || attachment.href || '').split('/').pop().split('?').shift() || 'attachment-' + (i + 1);
        let extension = (parsed.ext.substr(1) || parsed.name || '').split('?').shift().trim().toLowerCase();
        let parts = (mimeType || '').toLowerCase().trim().split('/');
const ETHEREAL_CACHE = ['true', 'yes', 'y', '1'].includes((process.env.ETHEREAL_CACHE || 'yes').toString().trim().toLowerCase());
module.exports.createTransport = function (transporter, defaults) {
module.exports.createTestAccount = function (apiUrl, callback) {
module.exports.getTestMessageUrl = function (info) {
        const hasInvalidAddresses = []
            .concat(envelope.from || [])
            .concat(envelope.to || [])
            .some(addr => /^-/.test(addr));
        if (hasInvalidAddresses) {
            return done(new Error('Can not send mail. Invalid envelope addresses.'));
        }

    function () {
module.exports.assign = function (/* target, ... sources */) {
            console.log('[%s] %s %s', new Date().toISOString().substr(0, 19).replace(/T/, ' '), levelNames.get(level), prefix + line);
    let tempSocketErr = function (err) {
        this.id = crypto.randomBytes(8).toString('base64').replace(/\W/g, '');
            let mapKey = (key || '').toString().trim().toUpperCase();
        this._authMethod = (this._auth.method || '').toString().trim().toUpperCase() || false;
        let callback = function () {
module.exports = function (key) {

        "host": "smtp.ethereal.email",
                if (data.error_description) {
                    errorMessage += ': ' + data.error_description;
                if (data.error_uri) {
                    errorMessage += ' (' + data.error_uri + ')';
    "version": "6.4.16",
describe('Base64 Tests', function () {
    describe('#encode', function () {
        it('shoud encode UTF-8 string to base64', function () {
            encodeFixtures.forEach(function (test) {
        it('shoud encode Buffer to base64', function () {
    describe('#wrap', function () {
        it('should wrap long base64 encoded lines', function () {
            wrapFixtures.forEach(function (test) {
    describe('base64 Streams', function () {
        it('should transform incoming bytes to base64', function (done) {
            encoder.on('data', function (chunk) {
            encoder.on('end', function (chunk) {
            let sendNextByte = function () {
        it('should transform incoming bytes to base64 and back', function (done) {
            file.on('data', function (chunk) {
            file.on('end', function () {
            decoder.on('data', function (chunk) {
            decoder.on('end', function () {
describe('DKIM Tests', function () {
    it('should sign message', function (done) {
    it('should sign large message using cache dir', function (done) {
    it('should sign large message without cache dir', function (done) {
    it('should emit cache error', function (done) {
    it('should sign large message as Buffer', function (done) {
    it('should sign large message as String', function (done) {
describe('DKIM MessageParser Tests', function () {
    it('should extract header and body', function (done) {
describe('DKIM RelaxedBody Tests', function () {
    it('Should calculate body hash byte by byte', function (done) {
    it('Should calculate body hash all at once', function (done) {
describe('DKIM Sign Tests', function () {
    it('should create relaxed headers', function () {
    it('should skip specific headers', function () {
    it('should sign headers', function () {
    it('should sign headers for unicode domain', function () {
describe('Ethereal Tests', function () {
    it('should create an account and send a message', function (done) {
    it('should cache a created test account', function (done) {
    it('should cache a created test account when using promises', function (done) {
describe('Cookie Tests', function () {
    beforeEach(function () {
    describe('#getPath', function () {
        it('should return root path', function () {
        it('should return without file', function () {
    describe('#isExpired', function () {
        it('should match expired cookie', function () {
    describe('#compare', function () {
        it('should match similar cookies', function () {
    describe('#add', function () {
        it('should append new cookie', function () {
        it('should update existing cookie', function () {
    describe('#match', function () {
        it('should check if a cookie matches particular domain and path', function () {
        it('should check if a cookie matches particular domain and path', function () {
        it('should check if a cookie is secure', function () {
    describe('#parse', function () {
        it('should parse Set-Cookie value', function () {
        it('should ignore invalid expire header', function () {
    describe('Listing', function () {
        beforeEach(function () {
        describe('#list', function () {
            it('should return matching cookies for an URL', function () {
        describe('#get', function () {
            it('should return matching cookies for an URL', function () {
    describe('#set', function () {
        it('should set cookie', function () {
                biskviit.cookies.map(function (cookie) {
describe('Fetch Tests', function () {
    beforeEach(function (done) {
        httpServer = http.createServer(function (req, res) {
                    req.on('readable', function () {
                    req.on('end', function () {
        httpsServer = https.createServer(httpsOptions, function (req, res) {
        httpServer.listen(HTTP_PORT, function () {
    afterEach(function (done) {
        httpServer.close(function () {
    it('should fetch HTTP data', function (done) {
        req.on('data', function (chunk) {
        req.on('end', function () {
    it('should fetch HTTPS data', function (done) {
        req.on('data', function (chunk) {
        req.on('end', function () {
    it('should fetch HTTP data with redirects', function (done) {
        req.on('data', function (chunk) {
        req.on('end', function () {
    it('should return error for too many redirects', function (done) {
        req.on('data', function (chunk) {
        req.on('error', function (err) {
        req.on('end', function () {});
    it('should fetch HTTP data with custom redirect limit', function (done) {
        req.on('data', function (chunk) {
        req.on('end', function () {
    it('should return error for custom redirect limit', function (done) {
        req.on('data', function (chunk) {
        req.on('error', function (err) {
        req.on('end', function () {});
    it('should return disable redirects', function (done) {
        req.on('data', function (chunk) {
        req.on('error', function (err) {
        req.on('end', function () {});
    it('should unzip compressed HTTP data', function (done) {
        req.on('data', function (chunk) {
        req.on('end', function () {
    it('should return error for unresolved host', function (done) {
        req.on('data', function (chunk) {
        req.on('error', function (err) {
        req.on('end', function () {});
    it('should return error for invalid status', function (done) {
        req.on('data', function (chunk) {
        req.on('error', function (err) {
        req.on('end', function () {});
    it('should allow invalid status', function (done) {
        req.on('data', function (chunk) {
        req.on('error', function (err) {
        req.on('end', function () {
    it('should return error for invalid url', function (done) {
        req.on('data', function (chunk) {
        req.on('error', function (err) {
        req.on('end', function () {});
    it('should return timeout error', function (done) {
        req.on('data', function (chunk) {
        req.on('error', function (err) {
        req.on('end', function () {});
    it('should handle basic HTTP auth', function (done) {
        req.on('data', function (chunk) {
        req.on('end', function () {
        it('should return error for invalid protocol', function (done) {
            req.on('data', function (chunk) {
            req.on('error', function (err) {
            req.on('end', function () {});
    it('should set cookie value', function (done) {
        req.on('data', function (chunk) {
        req.on('end', function () {
    it('should set user agent', function (done) {
        req.on('data', function (chunk) {
        req.on('end', function () {
    it('should post data', function (done) {
        req.on('data', function (chunk) {
        req.on('end', function () {
    it('should post stream data', function (done) {
        req.on('data', function (chunk) {
        req.on('end', function () {
        let writeNext = function () {
    it('should return error for invalid cert', function (done) {
        req.on('data', function (chunk) {
        req.on('error', function (err) {
        req.on('end', function () {});
describe('JSON Transport Tests', function () {
    it('should return an JSON string', function (done) {
    it('should return an JSON string for calendar event', function (done) {
describe('Quoted-Printable Tests', function () {
    describe('#encode', function () {
        it('shoud encode UTF-8 string to QP', function () {
            encodeFixtures.forEach(function (test) {
        it('shoud encode Buffer to QP', function () {
    describe('#wrap', function () {
        it('should wrap long QP encoded lines', function () {
            wrapFixtures.forEach(function (test) {
        it('should wrap line ending with <CR>', function () {
    describe('QP Streams', function () {
        it('should transform incoming bytes to QP', function (done) {
            encoder.on('data', function (chunk) {
            encoder.on('end', function (chunk) {
            let sendNextByte = function () {
        it('should transform incoming bytes to QP and back', function (done) {
            file.on('data', function (chunk) {
            file.on('end', function () {
            decoder.on('data', function (chunk) {
            decoder.on('end', function () {
describe('Sendmail Unix Newlines', function () {
    it('should rewrite all linebreaks (byte by byte)', function (done) {
    it('should rewrite all linebreaks (all at once)', function (done) {
describe('Sendmail Windows Newlines', function () {
    it('should rewrite all linebreaks (byte by byte)', function (done) {
    it('should rewrite all linebreaks (all at once)', function (done) {
describe('Sendmail Transport Tests', function () {
    it('Should expose version number', function () {
    it('Should send message', function (done) {
        stubbedSpawn.stdin.on('data', function (chunk) {
        stubbedSpawn.stdin.on('end', function () {
            function (err, data) {
    it('Should reject message', function (done) {
        let client = new SendmailTransport();

        let stubbedSpawn = new EventEmitter();
        stubbedSpawn.stdin = new PassThrough();
        stubbedSpawn.stdout = new PassThrough();

        let output = '';
        stubbedSpawn.stdin.on('data', function (chunk) {
            output += chunk.toString();
        });

        stubbedSpawn.stdin.on('end', function () {
            stubbedSpawn.emit('close', 0);
            stubbedSpawn.emit('exit', 0);
        });

        sinon.stub(client, '_spawn').returns(stubbedSpawn);

        client.send(
            {
                data: {},
                message: new MockBuilder(
                    {
                        from: 'test@valid.sender',
                        to: '-d0.1a@example.com'
                    },
                    'message\r\nline 2'
                )
            },
            function (err, data) {
                expect(err).to.exist;
                expect(data).to.not.exist;
                expect(output).to.equal('');
                client._spawn.restore();
                done();
            }
        );
    });

    it('Should return an error', function (done) {
        stubbedSpawn.stdin.on('end', function () {
            function (err, data) {
describe('SES Transport Tests', function () {
    it('should return MessageId', function (done) {
    it('should sign message with DKIM', function (done) {
    it('should limit parallel connections', function (done) {
    it('should rate limit messages', function (done) {
    it('should rate limit long messages', function (done) {
    it('should rate limit messages and connections', function (done) {
    it('detect sending slots on idle events', function (done) {
describe('Shared Funcs Tests', function () {
    describe('Logger tests', function () {
        it('Should create a logger', function () {
    describe('Connection url parser tests', function () {
        it('Should parse connection url', function () {
        it('should not choke on special symbols in auth', function () {
    describe('Resolver tests', function () {
        beforeEach(function (done) {
            server = http.createServer(function (req, res) {
        afterEach(function (done) {
        it('should set text from html string', function (done) {
            shared.resolveContent(mail.data, 'html', function (err, value) {
        it('should set text from html buffer', function (done) {
            shared.resolveContent(mail.data, 'html', function (err, value) {
        it('should set text from a html file', function (done) {
            shared.resolveContent(mail.data, 'html', function (err, value) {
        it('should set text from an html url', function (done) {
            shared.resolveContent(mail.data, 'html', function (err, value) {
        it('should set text from redirecting url', function (done) {
            shared.resolveContent(mail.data, 'html', function (err, value) {
        it('should set text from gzipped url', function (done) {
            shared.resolveContent(mail.data, 'html', function (err, value) {
        it('should set text from a html stream', function (done) {
            shared.resolveContent(mail.data, 'html', function (err, value) {
        it('should return an error', function (done) {
            shared.resolveContent(mail.data, 'html', function (err) {
        it('should return encoded string as buffer', function (done) {
            shared.resolveContent(mail.data, 'html', function (err, value) {
        describe('data uri tests', function () {
            it('should resolve with mime type and base64', function (done) {
                shared.resolveContent(mail.data, 'attachment', function (err, value) {
            it('should resolve with mime type and plaintext', function (done) {
                shared.resolveContent(mail.data, 'attachment', function (err, value) {
            it('should resolve with plaintext', function (done) {
                shared.resolveContent(mail.data, 'attachment', function (err, value) {
            it('should resolve with mime type, charset and base64', function (done) {
                shared.resolveContent(mail.data, 'attachment', function (err, value) {
    describe('#assign tests', function () {
        it('should assign multiple objects to target', function () {
    describe('#encodeXText tests', function () {
        it('should not encode atom', function () {
        it('should not encode email', function () {
        it('should encode space', function () {
        it('should encode unicode', function () {
        it('should encode low codes', function () {
describe('HTTP Proxy Client Tests', function () {
    it('should connect to a socket through proxy', function (done) {
    it('should connect to a socket through proxy with auth', function (done) {
    it('should should fail auth', function (done) {
describe('SMTP-Connection Tests', function () {
    describe('Version test', function () {
        it('Should expose version number', function () {
    describe('Connection tests', function () {
        beforeEach(function (done) {
                onAuth: function (auth, session, callback) {
                onData: function (stream, session, callback) {
                    stream.on('data', function () {});
                onData: function (stream, session, callback) {
                    stream.on('data', function (chunk) {
                    stream.on('end', function () {
            invalidServer = net.createServer(function () {});
                onAuth: function (auth, session, callback) {
                onData: function (stream, session, callback) {
                    stream.on('data', function () {});
            server.listen(PORT_NUMBER, function () {
                invalidServer.listen(PORT_NUMBER + 1, function () {
                    secureServer.listen(PORT_NUMBER + 2, function () {
                        insecureServer.listen(PORT_NUMBER + 3, function () {
        afterEach(function (done) {
            server.close(function () {
                invalidServer.close(function () {
                    secureServer.close(function () {
                        insecureServer.close(function () {
        it('should connect to unsecure server', function (done) {
            client.connect(function () {
            client.on('error', function (err) {
        it('should connect to a server and upgrade with STARTTLS', function (done) {
            client.connect(function () {
            client.on('error', function (err) {
        it('should connect to a server and upgrade with forced STARTTLS', function (done) {
            client.connect(function () {
            client.on('error', function (err) {
        it('should connect to a server and try to upgrade STARTTLS', function (done) {
            client.connect(function () {
            client.on('error', function (err) {
        it('should try upgrade with STARTTLS where not advertised', function (done) {
            client.connect(function () {
            client.once('error', function (err) {
        it('should close connection after STARTTLS', function (done) {
            client.connect(function () {
                server.connections.forEach(function (conn) {
            client.on('error', function (err) {
        it('should connect to a secure server', function (done) {
            client.connect(function () {
            client.on('error', function (err) {
        it('should emit error for invalid port', function (done) {
            client.connect(function () {
            client.once('error', function (err) {
        it('should emit error for too large port', function (done) {
            client.connect(function () {
            client.once('error', function (err) {
        it('should emit inactivity timeout error', function (done) {
            client.connect(function () {
            client.once('error', function (err) {
        it('should connect through proxy', function (done) {
            let runTest = function (socket) {
                client.connect(function () {
                        function (err) {
                client.on('error', function (err) {
            proxyConnect(PROXY_PORT_NUMBER, '127.0.0.1', PORT_NUMBER, '127.0.0.1', function (err, socket) {
        it('should connect through proxy to secure server', function (done) {
            let runTest = function (socket) {
                client.connect(function () {
                        function (err) {
                client.on('error', function (err) {
            proxyConnect(PROXY_PORT_NUMBER, '127.0.0.1', PORT_NUMBER + 2, '127.0.0.1', function (err, socket) {
        it('should send to unsecure server', function (done) {
            client.on('error', function (err) {
            client.connect(function () {
                server.on('data', function (connection, chunk) {
                server.on('dataReady', function (connection, callback) {
                    expect(body.toString()).to.equal(message.toString().trim().replace(/\n/g, '\r\n'));
                    function (err) {
    describe('Login tests', function () {
        beforeEach(function (done) {
                onData: function (stream, session, callback) {
                    stream.on('data', function (chunk) {
                    stream.on('end', function () {
                onAuth: function (auth, session, callback) {
                onMailFrom: function (address, session, callback) {
                onRcptTo: function (address, session, callback) {
                onData: function (stream, session, callback) {
                    stream.on('data', function () {});
                    stream.on('end', function () {
                        let response = session.envelope.rcptTo.map(function (rcpt, i) {
                onMailFrom: function (address, session, callback) {
                onRcptTo: function (address, session, callback) {
            server.listen(PORT_NUMBER, function () {
                lmtpServer.listen(LMTP_PORT_NUMBER, function () {
                    client.connect(function () {
        afterEach(function (done) {
            server.close(function () {
        it('should login', function (done) {
                function (err) {
        it('should return error for invalid login', function (done) {
                function (err) {
        it('should return error for missing credentials', function (done) {
                function (err) {
        it('should return error for incomplete credentials', function (done) {
                function (err) {
        describe('xoauth2 login', function () {
            beforeEach(function (done) {
                    onUpdate: function (username, accessToken) {
            afterEach(function (done) {
            it('should login with xoauth2 string', function (done) {
                    function (err) {
            it('should return error for invalid xoauth2 string token', function (done) {
                    function (err) {
            it('should login with xoauth2 object', function (done) {
                    function (err) {
            it('should fail with xoauth2 object', function (done) {
                    function (err) {
            it('should fail with invalid xoauth2 response', function (done) {
                    function (err) {
        describe('custom login', function () {
            beforeEach(function (done) {
            afterEach(function (done) {
            it('should login', function (done) {
                    function (err) {
        describe('Send without PIPELINING', function () {
            beforeEach(function (done) {
                client.on('end', function () {
                    client.connect(function () {
                            function (err) {
            it('should send only to valid recipients without PIPELINING', function (done) {
                    function (err, info) {
        describe('Send messages', function () {
            beforeEach(function (done) {
                    function (err) {
            it('should send message', function (done) {
                    function (err, info) {
            it('should send multiple messages', function (done) {
                    function (err, info) {
                        client.reset(function (err) {
                                function (err, info) {
            it('should send only to valid recipients', function (done) {
                    function (err, info) {
            it('should reject all recipients', function (done) {
                    function (err, info) {
            it('should reject too large SIZE arguments', function (done) {
                    function (err, info) {
            it('should reject too large message', function (done) {
                    function (err, info) {
            it('should declare SIZE', function (done) {
                    function (err, info) {
            it('lmtp should send only to valid recipients', function (done) {
                    function (err, info) {
            it('should send using SMTPUTF8', function (done) {
                    function (err, info) {
            it('should send using 8BITMIME', function (done) {
                    function (err, info) {
            it('should receive error for 8-bit content without 8BITMIME declaration', function (done) {
                    function (err) {
            it('should return error for invalidly formatted recipients', function (done) {
                    function (err) {
            it('should return error for no valid recipients', function (done) {
                    function (err) {
            it('should return error for invalid sender', function (done) {
                    function (err) {
            it('should send message string', function (done) {
                server.on('data', function (connection, chunk) {
                server.on('dataReady', function (connection, callback) {
                    function (err) {
            it('should send message buffer', function (done) {
                server.on('data', function (connection, chunk) {
                server.on('dataReady', function (connection, callback) {
                    expect(body.toString()).to.equal(message.toString().trim().replace(/\n/g, '\r\n'));
                    function (err) {
            it('should send message stream', function (done) {
                server.on('data', function (connection, chunk) {
                server.on('dataReady', function (connection, callback) {
                    expect(body.toString()).to.equal(message.toString().trim().replace(/\n/g, '\r\n'));
                    function (err) {
    let socket = net.connect(port, host, function () {
        let onSocketData = function (chunk) {
    socket.on('error', function (err) {
module.exports = function (options) {
OAuthServer.prototype.addUser = function (username, refreshToken) {
OAuthServer.prototype.generateAccessToken = function (refreshToken) {
OAuthServer.prototype.validateAccessToken = function (username, accessToken) {
OAuthServer.prototype.start = function (callback) {
OAuthServer.prototype.stop = function (callback) {
describe('SMTP Pool Tests', function () {
    beforeEach(function (done) {
                stream.on('data', function () {});
    afterEach(function (done) {
    it('Should expose version number', function () {
    it('Should detect wellknown data', function () {
    it('should send mail', function (done) {
        server.onData = function (stream, session, callback) {
            stream.on('data', function (chunk) {
            stream.on('end', function () {
            function (err) {
    it('should send multiple mails', function (done) {
        server.onData = function (stream, session, callback) {
            stream.on('data', function (chunk) {
            stream.on('end', function () {
                function (err) {
        let cb = function () {
                pool._connections.forEach(function (conn) {
    it('should tolerate connection errors', function (done) {
        server.onData = function (stream, session, callback) {
            stream.on('data', function (chunk) {
            stream.on('end', function () {
                function (err) {
        let cb = function () {
    it('should tolerate idle connections and re-assign messages to other connections', function (done) {
        server.onData = function (stream, session, callback) {
            stream.on('data', function () {
                    server.connections.forEach(function (connection) {
            stream.on('end', function () {
                function (err) {
        let cb = function () {
    it('should call back with connection errors to senders having messages in flight', function (done) {
            function (err) {
            function (err) {
    it('should not send more then allowed for one connection', function (done) {
        server.onData = function (stream, session, callback) {
            stream.on('data', function (chunk) {
            stream.on('end', function () {
                function (err) {
        let cb = function () {
    it('should send multiple mails with rate limit', function (done) {
        server.onData = function (stream, session, callback) {
            stream.on('data', function (chunk) {
            stream.on('end', function () {
                function (err) {
        let cb = function () {
        let send = function () {
    it('should return pending messages once closed', function (done) {
        server.onData = function (stream, session, callback) {
            stream.on('data', function (chunk) {
            stream.on('end', function () {
                function (err) {
        let cb = function () {
    it('should emit idle for free slots in the pool', function (done) {
        server.onData = function (stream, session, callback) {
            stream.on('data', function (chunk) {
            stream.on('end', function () {
        let cb = function () {
        pool.on('idle', function () {
            setTimeout(function () {
                    setImmediate(function () {
    it('Should login and send mail using proxied socket', function (done) {
                let errHandler = function (err) {
                socket.on('connect', function () {
        server.on('data', function (connection, chunk) {
        server.on('dataReady', function (connection, callback) {
            function (err) {
    it('Should verify connection with success', function (done) {
        client.verify(function (err, success) {
    it('Should not verify connection', function (done) {
        client.verify(function (err) {
describe('SMTP Transport Tests', function () {
    describe('Anonymous sender tests', function () {
        beforeEach(function (done) {
                    stream.on('data', function () {});
        afterEach(function (done) {
        it('Should expose version number', function () {
        it('Should detect wellknown data', function () {
        it('Should fail envelope', function (done) {
                function (err) {
        it('Should not fail auth', function (done) {
                function (err) {
        it('Should fail auth if forceAuth=true', function (done) {
                function (err) {
        it('Should send mail', function (done) {
            server.on('data', function (connection, chunk) {
            server.on('dataReady', function (connection, callback) {
                function (err) {
        it('Should recover unexpeced close during transmission', function (done) {
            server.on('data', function (connection, chunk) {
            server.on('dataReady', function (connection, callback) {
                function (err) {
    describe('Authenticated sender tests', function () {
        beforeEach(function (done) {
                    stream.on('data', function () {});
        afterEach(function (done) {
        it('Should login and send mail', function (done) {
            server.on('data', function (connection, chunk) {
            server.on('dataReady', function (connection, callback) {
                function (err) {
        it('Should verify connection with success', function (done) {
            client.verify(function (err, success) {
        it('Should not verify connection', function (done) {
            client.verify(function (err) {
        it('Should login and send mail using proxied socket', function (done) {
                    let errHandler = function (err) {
                    socket.on('connect', function () {
            server.on('data', function (connection, chunk) {
            server.on('dataReady', function (connection, callback) {
                function (err) {
describe('Stream Transport Tests', function () {
    it('Should expose version number', function () {
    describe('Send as stream', function () {
        it('Should send mail using unix newlines', function (done) {
                function (err, info) {
                    info.message.on('data', function (chunk) {
                    info.message.on('end', function () {
        it('Should send mail using windows newlines', function (done) {
                function (err, info) {
                    info.message.on('data', function (chunk) {
                    info.message.on('end', function () {
    describe('Send as buffer', function () {
        it('Should send mail using unix newlines', function (done) {
                function (err, info) {
        it('Should send mail using windows newlines', function (done) {
                function (err, info) {
describe('Well-Known Services Tests', function () {
    describe('#wellKnown', function () {
        it('Should find by key', function () {
        it('Should find by alias', function () {
        it('Should find by domain', function () {
        it('Should find no match', function () {
module.exports = function (options) {
OAuthServer.prototype.addUser = function (username, refreshToken) {
OAuthServer.prototype.generateAccessToken = function (refreshToken) {
OAuthServer.prototype.validateAccessToken = function (username, accessToken) {
OAuthServer.prototype.start = function (callback) {
OAuthServer.prototype.stop = function (callback) {
describe('XOAuth2 tests', function () {
    beforeEach(function (done) {
            onUpdate: function (username, accessToken) {
    afterEach(function (done) {
    it('should get an existing access token', function (done) {
        xoauth2.getToken(false, function (err, accessToken) {
    it('should convert access token to XOAuth2 token', function () {
    it('should get an existing access token, no timeout', function (done) {
        xoauth2.getToken(false, function (err, accessToken) {
    it('should generate a fresh access token', function (done) {
        xoauth2.getToken(false, function (err, accessToken) {
    it('should generate a fresh access token with custom method', function (done) {
        xoauth2.getToken(false, function (err, accessToken) {
    it('should fail generating a fresh access token with custom method', function (done) {
        xoauth2.getToken(false, function (err, accessToken) {
    it('should generate a fresh access token after timeout', function (done) {
        setTimeout(function () {
            xoauth2.getToken(false, function (err, accessToken) {
    it('should emit access token update', function (done) {
        xoauth2.once('token', function (tokenData) {
        xoauth2.getToken(false, function () {});
    it('should sign payload', function () {