upnode-cluster-smtp
v1.1.1
Published
Provides 2 pluggable RPC calls: one generates smtp pool, and the other is responsible for generating smtp access credentials cache
Downloads
11
Maintainers
Readme
Upnode cluster smtp extension
Plugin for upnode-cluster, adds methods for handling distributed email messaging
Install
npm install upnode-cluster upnode-cluster-smtp -S
Usage
var Node = require('upnode-cluster');
var SMTPResources = require('upnode-cluster-smtp');
var resources = {};
SMTPResources.init(resources, {
gmail_oauth_appid: {
clientId: '',
clientSercret: ''
}
}, function prepareEmail(rawNodemailerOpts) {
// will be preprocessed on the node locally
});
var node = new Node({
// ...
resources: resources
});
// then you can use it
var opts = {
provider: 'gmail',
user: '[email protected]',
type: 'oauth',
credentialsResourceName: 'gmail_oauth_appid',
credentials: {
refreshToken: '<refresh token>',
accessToken: '<access token>'
}
};
var self = this;
var nodeId = this.node.server.id;
node.acquireResource('[email protected]', 'SMTP', opts).then(function (resourceHolderId) {
var nodemailerOpts = {}; // whatever nodemailer accepts
return self.callResource(resourceHolderId, '[email protected]', 'SMTP', { email: nodemailerOpts, options: opts });
}).nodeify(function (err, response) {
// either that or promises
});