chainmail

0.0.3 • Public • Published

chainmail

chaining api for mandrill in node

Installation

npm install chainmail

Usage

Initialization and quick example

var chainmail = require('chainmail')(mandrillApiKey)
chainmail.sendTemplate('welcome-email')
  .to('user@server.com')
  .withGlobalVars({couponCode: '345ZX'})
  .exec(function() { console.log('email sent!') })


sendTemplate()

returns a template object

var template = chainmail.sendTemplate('welcome-mail')

Arguments

  • templateName - the name of the template you're sending

Template

Object that sends a mandrill email template

to()

Describes the recipients of the email. Returns the template object.

template.to('email@server.com')
template.to(['email@server.com', 'email2@server.com'])
template.to([{e: 'email@server.com'}, {e: 'email2@server.com}], function(r) { return {email: r.e}} })

Arguments

  • emails - the email, array of emails or array of objects to send the email to
  • [mapFn] - if providing an array of objects, the function that maps the object to email info

withGlobalVars()

Sets the template variables that should be populated for every recipient. Returns the template object.

template.withGlobalVars({ couponCode: '4563Z' })

Arguments

  • varMap - object where the keys signify var names and the value signify var values

withVars()

Sets the template variable that differ for each recipient. Returns the template object.

template.withVars(function(e) { return { couponCode: '4563Z' }})

Arguments

  • varFn - Function that accepts the email object set in to and creates a varMap

andAttachCsv()

Create a csv attachment. Returns the template object.

template.andAttachCsv('attach.csv', new Buffer('file contents'))

Arguments

  • fileName - Name of attachment
  • fileContents - Buffer of attachment contents

exec()

Submits mail request.

template.exec(function() {console.log('Woo hoo!')})

Arguments

  • cb - Callback function. Takes an err and response argument.

Readme

Keywords

none

Package Sidebar

Install

npm i chainmail

Weekly Downloads

2

Version

0.0.3

License

MIT

Last publish

Collaborators

  • jperkelens