rf-api-mailer

0.5.5 • Public • Published

rf-api-mailer

Gets Mails settings and starts simpleTemplateMailer.

Getting Started

npm install rf-api-mailer

Init the service

 
var mailerOptions ={
   transporter: mainOptions., // nodemailer transporter
   defaultLanguage: 'en',
   contactMail: 'your@contactMail.com' // optional
   translationsPath: 'mail/translations',
   templatesPath: 'mail/templates',
   inlineAttribute: 'inline' // all html tags with this attribute will be "inlined" by "inline-source"
});
 
var services: {
   sendMail: require('rf-api-mailer').start(mailerOptions).sendMail
}
 

Assuming, that templates and translations are in one folder you might pass the path options direct like:

 
var mailerOptions ={
   transporter: mainOptions., // nodemailer transporter
   defaultLanguage: 'en',
   contactMail: 'your@contactMail.com' // optional
});
 
var mailPath = 'mail';
 
var services: {
   sendMail: require('rf-api-mailer').start(mailerOptions, mailPath).sendMail
}
 

Use the service

 
var template = {
   name: 'newsletter',
   language: "en",
   data: {test: 234} // data from your app inserted in template
   inlineAttribute: "inline" // optional: individual inline configuration
};
 
var mailOptions = {to:["max.mustermann@gmx.net"]}; // nodemailer options
 
 
// simple example
services.sendMail(template, mailOptions, function(err, data){
   console.log(err, data)
});
 
// with rf-api
API.post('/sendmail', function(req, res){
   services.sendMail(req.data.template, req.data.mailOptions, res.send);
})
 

Development

Install the dev tools with

npm install

Then you can runs some test cases and eslint with:

npm test

Legal Issues

  • License: MIT
  • Author: Rapidfacture GmbH

Readme

Keywords

none

Package Sidebar

Install

npm i rf-api-mailer

Weekly Downloads

0

Version

0.5.5

License

MIT

Unpacked Size

10.4 kB

Total Files

5

Last publish

Collaborators

  • ghofmockel
  • felix_furtmayr
  • jochenh
  • ulikoehler
  • rf-bernhard
  • max_speedy
  • mitzenthaler