Skip to content

Commit

Permalink
Merge pull request #33 from hdon/master
Browse files Browse the repository at this point in the history
added devHost option
  • Loading branch information
GreenPioneer authored May 17, 2017
2 parents 2e120b1 + 4908cc7 commit 944c487
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sendmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = function (options) {
const dkimPrivateKey = (options.dkim || {}).privateKey;
const dkimKeySelector = (options.dkim || {}).keySelector || 'dkim';
const devPort = options.devPort || -1;
const devHost = options.devHost || 'localhost';

/*
* 邮件服务返回代码含义 Mail service return code Meaning
Expand Down Expand Up @@ -101,15 +102,15 @@ module.exports = function (options) {

tryConnect(0)
})
} else { // development mode -> connect to the specified devPort on localhost
const sock = createConnection(devPort);
} else { // development mode -> connect to the specified devPort on devHost
const sock = createConnection(devPort, devHost);

sock.on('error', function (err) {
callback(new Error('Error on connectMx (development) for "localhost:' + devPort + '": ' + err))
callback(new Error('Error on connectMx (development) for "'+ devHost +':' + devPort + '": ' + err))
});

sock.on('connect', function () {
logger.debug('MX (development) connection created: localhost:' + devPort);
logger.debug('MX (development) connection created: '+ devHost +':' + devPort);
sock.removeAllListeners('error');
callback(null, sock)
})
Expand Down

0 comments on commit 944c487

Please sign in to comment.