engined-mailer-gmail
v0.0.3
Published
Mailer agent with gmail service for engined
Downloads
1
Readme
engined-mailer-gmail
Local mailer use gmail backend for engined.
Installation
Install via NPM:
npm install engined-mailer-gmail
Usage
Start engined-mailer-gmail service in engined, see example below:
const { Manager } = require('engined');
const MailerService = require('engined-mailer');
const LocalMailerService = require('engined-mailer-gmail');
const mailer = MailerService();
const localMailer = LocalMailerService({
type: 'OAuth2',
user: config.get('mailer').auth.user,
pass: config.get('mailer').auth.pass,
clientId: config.get('mailer').auth.clientId,
clientSecret: config.get('mailer').auth.clientSecret,
refreshToken: config.get('mailer').auth.refreshToken,
accessToken: config.get('mailer').auth.accessToken
});
const main = async () => {
// Create manager
let serviceManager = new Manager({ verbose: true });
// Adding service to manager
serviceManager.add('Mailer', mailer);
serviceManager.add('LocalMailer', localMailer);
// Start all services
await serviceManager.startAll();
};
main();
Send email with local mailer backend
The example to show how to send email with local mailer backend:
// Using local mailer backend
let localAgent = this.getContext().get('Mailer').getAgent('default');
// Send Email with token
localAgent.sendMailWithTokens({
from: config.get('mailer').sender.name + ' <' + config.get('mailer').sender.address + '>',
to: '[email protected]',
subject: 'test',
html: '<p>1234</p>'
})
// Send Email with password
localAgent.sendMailWithPass({
from: config.get('mailer').sender.name + ' <' + config.get('mailer').sender.address + '>',
to: '[email protected]',
subject: 'test',
html: '<p>1234</p>'
})
License
Licensed under the MIT License
Authors
Copyright(c) 2017 Leon Lin(林為志) <[email protected]>