node-mandrill
A simple node.js wrapper for MailChimp's Mandrill API
Documentation
Usage
Constructor options
MANDRILL_API_KEY
{String} api key value (can also be specified with environment variableMANDRILL_API_KEY
)DEFAULT_FROM_EMAIL
{String} default from email (optional)DEFAULT_FROM_NAME
{String} default from name (optional)DEFAULT_TEMPLATE_OPTIONS
{Object} default template options (optional)
Methods
instance.send(options)
Return a fulfilled promise with mandrill response. See Below for options
schema
instance.send(templateName, options)
Return a fulfilled promise with mandrill response. See Below for options
schema
Options Schema
to
{String/Array} email recipient or array of emails recipientscc
{String/Array} email carbon copy or array of emails carbon copies (optional)bcc
{String/Array} email blind carbon copy or array of emails blind carbon copies (optional)subject
{String} email subject (optional)html
{String} email HTML code (optional) (can be use only forsend
)text
{String} email text (optional) (can be use only forsend
)global_merge_vars
{Object} global merge vars, (optional) (see Mandrill documentation for more informations on it)attachments
{Array} array of attachments files (optional)
Examples
const Mandrill = ; const mailer = MANDRILL_API_KEY: 'MY_MANDRILL_API_KEY' DEFAULT_FROM_EMAIL: 'no-reply@email.com' DEFAULT_FROM_NAME: 'no-reply' DEFAULT_TEMPLATE_OPTIONS: global_merge_vars: 'name': 'COMPANY' 'content': 'My Company' ; mailer; // => return Promise mailer; // => return Promise
Send attachments
const Mandrill = ;const fs = ; const mailer = ; // using MANDRILL_API_KEY defined in environment variable mailer; // => return Promise
TODO
- unit test
Contributing
This project is a work in progress and subject to API changes, please feel free to contribute