nodemailer-smtp-pool
Advanced tools
Comparing version 1.1.6 to 1.2.0
{ | ||
"name": "nodemailer-smtp-pool", | ||
"version": "1.1.6", | ||
"version": "1.2.0", | ||
"description": "SMTP transport for Nodemailer", | ||
@@ -26,3 +26,3 @@ "main": "src/smtp-pool.js", | ||
"nodemailer-wellknown": "^0.1.7", | ||
"smtp-connection": "^1.3.3" | ||
"smtp-connection": "^1.3.7" | ||
}, | ||
@@ -29,0 +29,0 @@ "devDependencies": { |
@@ -44,2 +44,4 @@ # SMTP transport module for Nodemailer | ||
Alternatively you can use connection url with protocol 'smtp:' or 'smtps:'. Use query arguments for additional configuration values. | ||
Pooled SMTP transport uses the same options as [SMTP transport](https://github.com/andris9/nodemailer-smtp-transport) with the addition of **maxConnections** and **maxMessages**. | ||
@@ -66,2 +68,10 @@ | ||
Or with connection url (gmail) | ||
```javascript | ||
var transporter = nodemailer.createTransport( | ||
smtpTransport('smtps://username%40gmail.com:password@smtp.gmail.com') | ||
); | ||
``` | ||
## Authentication | ||
@@ -68,0 +78,0 @@ |
@@ -10,2 +10,3 @@ 'use strict'; | ||
var util = require('util'); | ||
var urllib = require('url'); | ||
@@ -28,5 +29,9 @@ // expose to the world | ||
if (options && typeof options === 'string') { | ||
options = { | ||
url: options | ||
}; | ||
} | ||
this.options = options && clone(options) || {}; | ||
this.options.maxConnections = this.options.maxConnections || 5; | ||
this.options.maxMessages = this.options.maxMessages || 100; | ||
@@ -41,2 +46,39 @@ if (this.options.service && (hostData = wellknown(this.options.service))) { | ||
// parse a configuration URL into configuration options | ||
if (this.options.url) { | ||
[urllib.parse(this.options.url, true)].forEach(function (url) { | ||
var auth; | ||
this.options.secure = url.protocol === 'smtps:'; | ||
if (!isNaN(url.port) && Number(url.port)) { | ||
this.options.port = Number(url.port); | ||
} | ||
if (url.hostname) { | ||
this.options.host = url.hostname; | ||
} | ||
if (url.auth) { | ||
auth = url.auth.split(':'); | ||
if (!this.options.auth) { | ||
this.options.auth = {}; | ||
} | ||
this.options.auth.user = decodeURIComponent(auth[0]); | ||
this.options.auth.pass = decodeURIComponent(auth[1]); | ||
} | ||
Object.keys(url.query || {}).forEach(function (key) { | ||
if (!(key in this.options)) { | ||
this.options[key] = url.query[key]; | ||
} | ||
}.bind(this)); | ||
}.bind(this)); | ||
} | ||
this.options.maxConnections = this.options.maxConnections || 5; | ||
this.options.maxMessages = this.options.maxMessages || 100; | ||
// temporary object | ||
@@ -43,0 +85,0 @@ var connection = new SMTPConnection(this.options); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23027
498
148
Updatedsmtp-connection@^1.3.7