Skip to content

Commit

Permalink
#49 added smtpHost to add extra smtp host after resolveMX
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenPioneer committed Mar 14, 2018
1 parent 7621364 commit 9c3f0fe
Show file tree
Hide file tree
Showing 5 changed files with 1,391 additions and 6 deletions.
16 changes: 13 additions & 3 deletions Readme.md
Expand Up @@ -38,9 +38,10 @@ const sendmail = require('sendmail')({
privateKey: fs.readFileSync('./dkim-private.pem', 'utf8'),
keySelector: 'mydomainkey'
},
devPort: 1025 // Default: False
devHost: 'localhost' // Default: localhost
smtpPort: 2525 // Default: 25
devPort: 1025, // Default: False
devHost: 'localhost', // Default: localhost
smtpPort: 2525, // Default: 25
smtpHost: 'localhost' // Default: -1 - extra smtp host after resolveMX
})
```

Expand Down Expand Up @@ -68,6 +69,7 @@ Please checkout our great examples
- **[meetingRequest.js](https://github.com/guileen/node-sendmail/blob/master/examples/meetingRequest.js)**
- **[simple.js](https://github.com/guileen/node-sendmail/blob/master/examples/simple.js)**
- **[devHostPort.js](https://github.com/guileen/node-sendmail/blob/master/examples/devHostPort.js)**
- **[smtpPort.js](https://github.com/guileen/node-sendmail/blob/master/examples/smtpPort.js)**

### Upgrading

Expand Down Expand Up @@ -140,8 +142,16 @@ Add option to override "localhost" when sending all SMTP traffic to a dummy serv
##### 1.3.0
Add option to override "smtpPort:25"

##### 1.4.0
Add option to add extra smtp host after resolveMX "smtpHost:-1"
Added Yarn Lock

### Roadmap

* Add Testing
* Add Better Error Handling
* Add A Retry feature
* Update how we do options
* Respond with documented status codes
* CRLF
* Please submit your ideas as PR's
15 changes: 15 additions & 0 deletions examples/smtpPort.js
@@ -0,0 +1,15 @@
var sendmail = require('../sendmail')({
smtpHost:'localhost',
smtpPort: 1025
})

sendmail({
from: 'test@yourdomain.com',
to: 'info@yourdomain.com',
replyTo: 'jason@yourdomain.com',
subject: 'MailComposer sendmail',
html: 'Mail of test sendmail '
}, function (err, reply) {
console.log(err && err.stack)
console.dir(reply)
})
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"author": "Gui Lin <guileen@gmail.com>",
"name": "sendmail",
"description": "Sendmail without setting up SMTP server",
"version": "1.3.0",
"version": "1.4.0",
"repository": {
"type": "git",
"url": "git://github.com/guileen/node-sendmail.git"
Expand Down
4 changes: 2 additions & 2 deletions sendmail.js
Expand Up @@ -22,7 +22,7 @@ module.exports = function (options) {
const devPort = options.devPort || -1;
const devHost = options.devHost || 'localhost';
const smtpPort = options.smtpPort || 25

const smtpHost = options.smtpHost || -1
/*
* 邮件服务返回代码含义 Mail service return code Meaning
* 500 格式错误,命令不可识别(此错误也包括命令行过长)format error, command unrecognized (This error also includes command line too long)
Expand Down Expand Up @@ -83,7 +83,7 @@ module.exports = function (options) {
if (!data || data.length === 0) {
return callback(new Error('can not resolve Mx of <' + domain + '>'))
}

if(smtpHost !== -1)data.push({exchange:smtpHost})
function tryConnect (i) {
if (i >= data.length) return callback(new Error('can not connect to any SMTP server'));

Expand Down

0 comments on commit 9c3f0fe

Please sign in to comment.