Coder Social home page Coder Social logo

rf-api-mailer's Introduction

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: '[email protected]' // 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: '[email protected]' // 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:["[email protected]"]}; // 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

rf-api-mailer's People

Contributors

felixfurtmayr avatar rf-alex avatar web-mi avatar

Watchers

Uli Köhler avatar James Cloos avatar  avatar Regina Galambos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.