Loading...
Skip to main content

Mandrill

Profile Requirements

To deliver a message to a recipient over Mandrill, Courier must be provided the recipient's email address. This value should be included in the recipient profile as email.

{
"message": {
// Recipient Profile
"to": {
"email": "example@example.com"
}

// ... rest of message definition
}
}

Override

Overrides

Overrides occur after the render step in the notification lifecycle. This means the the rendered tab in the logs page will not show the end result for a notification that was rendered with overrides.

You can use a provider override to replace what we send to Mandrill's Messages API. For example, you can add an attachment to your request:

{
"message": {
"template": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"to": {
"email": "example@example.com"
},
"providers": {
"mandrill": {
"override": {
"body": {
"message": {
"from_email": "me@courier.com",
"subject": "Hi there",
"from_name": "Rod",
"attachments": [
{
"type": "text/plain",
"name": "myfile.txt",
"content": "ZXhhbXBsZSBmaWxl"
}
]
}
}
}
}
}
}
}

Everything inside of messageproviders.mandrill.override will replace what we send to Mandrill's Messages API. You can see all the available options by visiting Mandrill API docs.

Template Import

You can import your Mandrill templates to use with Courier from the Mandrill configuration page.

info

You will need to provide your Mandrill credentials in the configuration page to retrieve your saved templates from Mandrill.

Templates ready for import will appear as selectable checkboxes that you can choose to import.

Template Import Page

Troubleshooting

Dealing with Mandrill requests can result in some errors. You can find them below to help you troubleshoot. You can also check the Courier Logs to help debug any provier errors you may encounter. For anything else, you may contact Courier Support.

Mandrill Click Tracking Not Working

The three most possible causes are that you have not enabled click tracking, the URL is too long, so Mandrill has disabled click-tracking, or the clicks are recorded but not updated in real-time.

Solution

  • Verify whether click tracking is enabled.
    1. Login to the Mandrill account.
    2. Settings -> Sending defaults.
    3. Make sure your choice from the "Track Clicks" dropdown is something other than the "No click tracking" option.

Even though the opens and clicks get tracked in real-time, the status updates may delay from a few minutes to a more extended period. For instance, this may happen due to the load on their system. Courier provides its own link tracking which you can use to track clicks on your notification templates.

Mandrill BCC Not Working

Most possibly, Mandrill is ignoring the BCC headers and hence this error occurs.

Solution

  1. Try using the to field rather than the bcc field and set X-MC-PreserveRecipients to false.
  2. Or, specify the bcc address in the to field but declare their type as bcc. Add preserve_recipients: true under the message section. The code given below is an example of implementing this solution.
{
"to":[
{
"email":"to1.email@example.com",
"name":"To Recipient Name",
"type":"to"
},
{
"email":"bcc1.email.@example.com",
"name":"BCC1 Recipient Name",
"type":"bcc"
},
{
"email":"bcc2.email@example.com",
"name":"BCC2 Recipient Name",
"type":"bcc"
}
]
}

You can read more about X-MC-PreserveRecipients here

Mandrill Merge Vars Not Working

The cause for the Mandrill merge variables not working is possible because of an issue with the nesting.

Solution

You have to make sure the variables are nested in the message struct for it to work. Given below is an example of how it is done.

var message = {
to: "sample@gmail.com",
mandrillOptions: {
template_name: 'template1',
template_content: [
],
message: {
"merge": true,
"merge_language": "handlebars",
"global_merge_vars": [{
"name": "fname",
"content": "Sample"
},
{
"name": "email",
"content": "sample@gmail.com"
}
]
}
}
};