Add a new email template to a Mandrill account.
var Mandrill = require('machinepack-mandrill');
// Add a new email template to a Mandrill account.
Mandrill.addTemplate({
apiKey: '1dTOFDXzJdU5cXiMNd6jRq',
name: 'reset-your-password',
from_email: '[email protected]',
from_name: 'Harold Greaseworthy',
subject: 'Click the link in this email to reset your password',
code: '
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) {
},
});
A valid Mandrill API key.
'1dTOFDXzJdU5cXiMNd6jRq'
Name for the new template (must be unique to the account).
'reset-your-password'
A default sending address for emails sent using this template.
'[email protected]'
A default from name to be used for emails sent using this template.
'Harold Greaseworthy'
A default subject line to be used for emails sent using this template.
'Click the link in this email to reset your password'
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>'
A default text part to be used when sending with this template.
'Click on the following link to reset your password: \n *|RESET_LINK|*'
Set to false to add a draft template without publishing (defaults to true).
true
An optional array of up to 10 labels to use for filtering templates.
[ 'password' ]
An unexpected error occurred.
{
status: 'error',
code: 6,
name: 'Invalid_Template',
message: 'A template with name "machinepack-mandrill-test" already exists'
}
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
}