ms-mailer v11.0.1
Mailer Microservice
Sets up a rabbitmq consumer with QoS, and distributes incoming messages based on passed options
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
debug
- boolean, whether to print log messages or notprefix
- which route prefix to bind to, defaults tomailer
postfixAdhoc
- which suffix to use for adhoc messagingpostfixPredefined
- which suffix to use for predefined accounts messagingpredefinedLimits
- which opts to pass to smtp transport constructor for predefined accounts, consult nodemailer-smtp-transportamqp
- options that are passed toms-amqp-transport
htmlToText
- html to text conversion options for nodemaileraccounts
- predefined accounts that are initialized at service startup, format is the same as in the nodemailer smtp transport
Messaging format
- Adhoc messaging
mailer.adhoc
:
{
"account": String,
"email": {
// nodemailer email payload
}
}
- Predefined messaging
mailer.predefined
:
{
"account": {
// nodemailer smtp transport format
},
"email": {
// nodemailer email payload
}
}
Roadmap
- test dkim signing
- test different types of messages being sent
- test more error cases
- add QoS handling on demand
7 months ago
6 months ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago