10.7.0 • Published 2 years ago

ms-mailer v10.7.0

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

Mailer Microservice

Sets up a rabbitmq consumer with QoS, and distributes incoming messages based on passed options

npm version Build Status semantic-release Commitizen friendly codecov.io

Installation

npm i ms-mailer -S

Compatible with node >= 7.6.x

Usage

const Promise = require('bluebird');
const Mailer = require('ms-mailer');
const AMQP = require('@microfleet/transport-amqp');

const mailer = new Mailer({
  debug: Boolean,
  predefinedLimits: {
    maxConnections: Number,
    maxMessages: Number,
  },
  amqp: {
    // @microfleet/transport-amqp options
  },
  htmlToText: {
    // https://www.npmjs.com/package/html-to-text
  },
  accounts: {
    test: {
      // nodemailer smtp transport configuration
      service: 'yahoo',
      auth: {
        user: 'test@yahoo.com',
        pass: '123'
      }
    }
  }
});

// returns promise, which resolves when listeners are established
const mailerReady = mailer.connect();

Promise.props({ mailer: mailerReady, amqp: AMQP.connect() })
.then(function sendMessage(props) {
  const { amqp } = props;
  return amqp.publishAndWait('mailer.predefined', {
    account: 'test',
    email: {
      // nodemailer mail options
      // make sure not to pass streams or paths, as they can't be transferred through the wire
      // as the processing will be held on the other machine
      // in case you want to use some other services like S3, then an expansion can be coded for this module
    }
  });
})
.then(function sendMessageReponse(response) {
  // nodemailer smtp transport response
});

Configuration options

  1. debug - boolean, whether to print log messages or not
  2. prefix - which route prefix to bind to, defaults to mailer
  3. postfixAdhoc - which suffix to use for adhoc messaging
  4. postfixPredefined - which suffix to use for predefined accounts messaging
  5. predefinedLimits - which opts to pass to smtp transport constructor for predefined accounts, consult nodemailer-smtp-transport
  6. amqp - options that are passed to ms-amqp-transport
  7. htmlToText - html to text conversion options for nodemailer
  8. accounts - predefined accounts that are initialized at service startup, format is the same as in the nodemailer smtp transport

Messaging format

  1. Adhoc messaging mailer.adhoc:
{
  "account": String,
  "email": {
    // nodemailer email payload
  }
}
  1. Predefined messaging mailer.predefined:
{
  "account": {
    // nodemailer smtp transport format
  },
  "email": {
    // nodemailer email payload
  }
}

Roadmap

  1. test dkim signing
  2. test different types of messages being sent
  3. test more error cases
  4. add QoS handling on demand
10.7.0

2 years ago

10.6.0

2 years ago

10.5.0

3 years ago

10.4.0

3 years ago

10.3.0

3 years ago

10.2.8

3 years ago

10.2.7

3 years ago

10.2.6

3 years ago

10.2.4

3 years ago

10.2.5

3 years ago

10.2.3

3 years ago

10.2.2

3 years ago

10.2.1

3 years ago

10.2.0

3 years ago

10.1.0

3 years ago

10.0.4

3 years ago

10.0.3

3 years ago

10.0.2

3 years ago

10.0.1

3 years ago

10.0.0

4 years ago

9.0.0

5 years ago

8.3.2

5 years ago

8.3.1

5 years ago

8.3.0

5 years ago

8.2.0

5 years ago

8.1.1

5 years ago

8.1.0

5 years ago

8.0.1

6 years ago

8.0.0

6 years ago

7.0.7

6 years ago

7.0.6

6 years ago

7.0.5

7 years ago

7.0.4

7 years ago

7.0.3

7 years ago

7.0.2

7 years ago

7.0.1

7 years ago

7.0.0

7 years ago

6.0.0

7 years ago

5.1.1

7 years ago

5.1.0

7 years ago

5.0.2

7 years ago

5.0.1

7 years ago

5.0.0

7 years ago

4.0.0

7 years ago

3.2.3

7 years ago

3.2.2

7 years ago

3.2.1

7 years ago

3.2.0

7 years ago

3.1.0

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.1.0

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.5.2

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.2

8 years ago

0.1.1

8 years ago