expose mailer service as architect plugin.
npm install --save architect-mailer
{
packagePath: 'architect-mailer',
transport: {
tls: {
rejectUnauthorized: false,
},
ignoreTLS: true,
secure: false,
port: 25,
},
mail: {
config1: {
from : 'noreply@example.com',
}
}
}
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: 'someone@example.com',
subject: 'this the mail subject',
html: '<p>html message</p>'
}).then(() => {
console.log('mail sent !');
});
register();
};
// Consume rest plugin
module.exports.consumes=['mailer'];
- 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)