architect-mailer
v1.1.1
Published
architect mailer component
Downloads
558
Readme
architect-mailer
expose mailer service as architect plugin.
Installation
npm install --save architect-mailer
Config Format
{
packagePath: 'architect-mailer',
transport: {
tls: {
rejectUnauthorized: false,
},
ignoreTLS: true,
secure: false,
port: 25,
},
mail: {
config1: {
from : '[email protected]',
}
}
}
Usage
Boot Architect :
var path = require('path');
var architect = require("architect");
var configPath = path.join(__dirname, "config.js");
var config = architect.loadConfig(configPath);
architect.createApp(config, function (err, app) {
if (err) {
throw err;
}
console.log("app ready");
});
And use the service in your app :
module.exports = function setup(options, imports, register) {
var mailer = imports.mailer;
// send mail
mailer.config1.sendMail({
to: '[email protected]',
subject: 'this the mail subject',
html: '<p>html message</p>'
}).then(() => {
console.log('mail sent !');
});
register();
};
// Consume rest plugin
module.exports.consumes=['mailer'];
Options
- tansport : see nodemailer smtp or nodemailer other transports
- mail : a hash of configurations see nodemailer message configuration
- throttle: add a delay in ms when mail is sent to prevent flooding transport. (default: 0)