Mandrill.addTemplate()

Add a new email template to a Mandrill account.

Usage

Hover over inputs/exits for more info.

var Mandrill = require('machinepack-mandrill');


// Add a new email template to a Mandrill account.

Mandrill.addTemplate({

apiKey: '1dTOFDXzJdU5cXiMNd6jRq',

name: 'reset-your-password',

from_email: 'harold@foo.enterprise',

from_name: 'Harold Greaseworthy',

subject: 'Click the link in this email to reset your password',

code: '

Click here to reset your password.
',

text: 'Click on the following link to reset your password: \n *|RESET_LINK|*',

publish: true,

labels: [ 'password' ],

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

apiKey required

A valid Mandrill API key.

'1dTOFDXzJdU5cXiMNd6jRq'
name required

Name for the new template (must be unique to the account).

'reset-your-password'
from_email

A default sending address for emails sent using this template.

'harold@foo.enterprise'
from_name

A default from name to be used for emails sent using this template.

'Harold Greaseworthy'
subject

A default subject line to be used for emails sent using this template.

'Click the link in this email to reset your password'
code

The HTML code for the template with mc:edit attributes for the editable elements.

'<div>Click <a href="*|RESET_LINK|*">here</a> to reset your password.</div>'
text

A default text part to be used when sending with this template.

'Click on the following link to reset your password: \n *|RESET_LINK|*'
publish

Set to false to add a draft template without publishing (defaults to true).

true
labels

An optional array of up to 10 labels to use for filtering templates.

[ 'password' ]

Exits

error

An unexpected error occurred.

{ status: 'error',
  code: 6,
  name: 'Invalid_Template',
  message: 'A template with name "machinepack-mandrill-test" already exists' }
success

OK.

{ name: 'machinepack-mandrill-test',
  code: '<div>Click <a href="*|RESET_LINK|*">here</a> to reset your password.</div>',
  publish_code: null,
  created_at: '2014-05-28 21:59:49.70010',
  updated_at: '2014-05-28 21:59:49.70012',
  slug: 'machinepack-mandrill-test',
  publish_name: 'machinepack-mandrill-test',
  labels: [],
  text: 'Click on the following link to reset your password: \n *|RESET_LINK|*',
  publish_text: null,
  subject: null,
  publish_subject: null,
  from_email: null,
  publish_from_email: null,
  from_name: null }