A thin wrapper around iron-io/iron_mq_node for queuing up transactional emails.
It does this:
JSON.stringify()
's the request message bodyJSON.parse()
s the response message body- Returns a Q promise
The available email types and its payload can be found on fiestah/mailer.
// In app.js bootstrap
var mailq = require('mail-queue');
mailq.configure({
token: '...',
projectId: '...'
});
All methods return a Q promise, so you can chain them using .then()
or .fail()
and so on.
// Queue up an email, fire and forget. Logs to stderr if the request fails
mailq.post({
type: 'planner-welcome',
data: '4f70c613d0374f7813000001' // user id
});
// Clear the queue (useful for tests, automations etc.)
mailq.clear().then(function () {
// do something
})
.done();