nodemailer-smtp-pool
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "nodemailer-smtp-pool", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "SMTP transport for Nodemailer", | ||
@@ -25,3 +25,3 @@ "main": "src/smtp-transport.js", | ||
"nodemailer-wellknown": "^0.1.0", | ||
"smtp-connection": "^0.1.4" | ||
"smtp-connection": "^0.1.6" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
@@ -30,2 +30,3 @@ # SMTP transport module for Nodemailer | ||
* **options.secure** defines if the connection should use SSL (if `true`) or not (if `false`) | ||
* **options.auth** defines authentication data (see [authentication](#authentication) section below) | ||
* **options.ignoreTLS** turns off STARTTLS support if true | ||
@@ -60,5 +61,52 @@ * **options.name** optional hostname of the client, used for identifying to the server | ||
## Authentication | ||
If authentication data is not present, the connection is considered authenticated from the start. | ||
Set authentcation data with `options.auth` | ||
Where | ||
* **auth** is the authentication object | ||
* **auth.user** is the username | ||
* **auth.pass** is the password for the user | ||
* **auth.xoauth2** is the OAuth2 access token (preferred if both `pass` and `xoauth2` values are set) or an [XOAuth2](https://github.com/andris9/xoauth2) token generator object. | ||
If a [XOAuth2](https://github.com/andris9/xoauth2) token generator is used as the value for `auth.xoauth2` then you do not need to set the value for `auth.user`. XOAuth2 generator generates required `accessToken` itself if it is missing or expired. In this case if the authentication fails, a new token is requested and the authentication is retried once. If it still fails, an error is returned. | ||
Install xoauth2 module to use XOauth2 token generators (not included by default) | ||
npm install xoauth2 --save | ||
**XOAuth2 Example** | ||
```javascript | ||
var generator = require('xoauth2').createXOAuth2Generator({ | ||
user: '{username}', | ||
clientId: '{Client ID}', | ||
clientSecret: '{Client Secret}', | ||
refreshToken: '{refresh-token}', | ||
accessToken: '{cached access token}' // optional | ||
}); | ||
// listen for token updates | ||
// you probably want to store these to a db | ||
generator.on('token', function(token){ | ||
console.log('New token for %s: %s', token.user, token.accessToken); | ||
}); | ||
// login | ||
var transport = nodemailer.createTransport(smtpPool({ | ||
service: 'gmail', | ||
auth: { | ||
xoauth2: generator | ||
}, | ||
maxConnections: 5, | ||
maxMessages: 10 | ||
})); | ||
``` | ||
## Using well-known services | ||
If you do not want to specify the hostname, port and security settings for a well known service, you can use it by its name. | ||
If you do not want to specify the hostname, port and security settings for a well known service, you can use it by its name (case insensitive). | ||
@@ -65,0 +113,0 @@ ```javascript |
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
16035
131
Updatedsmtp-connection@^0.1.6