8.3.1 • Published 2 years ago

ms-mailer-client v8.3.1

Weekly downloads
136
License
MIT
Repository
github
Last release
2 years ago

Mailer microservice client

Encapsulates raw AMQP methods into a convenience wrapper.

Installation

npm i ms-mailer-client -S

Usage

const Mailer = require('ms-mailer-client');

const mailer = new Mailer(amqpTransport, {
  prefix: 'mailer',
  routes: {
    adhoc: 'adhoc',
    predefined: 'predefined'
  }
});

// use predefined email
const promisePredefined = mailer.send('support@makeomatic.ru', {
  // email body with nodemailer
});

// use adhoc account
const promiseAdhoc = mailer.send({
  // nodemailer smtp data
  service: 'gmail',
  auth: {

  }
}, {
  // nodemailer email body
});

send method

const Mailer = require('ms-mailer-client');
const mailer = new Mailer(transport, { /* config */ });

const promise = mailer.send('support@makeomatic.ru', {
  // nodemailer email body
  from: 'support@makeomatic.ru',
  to: 'test@example.com',
  subject: 'subj',
  text: 'some text',
  html: '<p>html version of some text</p>',
});

sendTemplate method

const Mailer = require('ms-mailer-client');
const mailer = new Mailer(transport, { /* config */ });

// can be used with adhoc account setup aswell
const promise = mailer.sendTemplate(
  'support@makeomatic.ru', 
  'reset', // template name
  {
    nodemailer: {
      from: 'support@makeomatic.ru',
      to: 'test@example.com',
      subject: 'subj',
    },
    ctx: {
      // template rendering context
      link: 'activation_link',
      name: 'John Doe',
    },
  }
);

Resulted promise can be fulfilled with rejection when the requested template name does not exist.

8.3.1

2 years ago

8.3.0

2 years ago

8.2.0

3 years ago

8.1.0

5 years ago

8.0.2

6 years ago

8.0.1

7 years ago

8.0.0

7 years ago

7.0.0

8 years ago

6.0.2

9 years ago

6.0.1

9 years ago

6.0.0

9 years ago

5.0.1

9 years ago

5.0.0

9 years ago

4.0.0

9 years ago

3.0.0

9 years ago

2.0.0

10 years ago

1.0.0

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago