Skip to content

Latest commit

 

History

History
93 lines (78 loc) · 2.61 KB

mandrill.md

File metadata and controls

93 lines (78 loc) · 2.61 KB

Mandrill transactionnal emails

Setup

For mandrill template, the default language is handlebars, you should use {{}} instead of *||*.

In your settings.json file, you'll need to add the following configuration object to the actions property:

  "actions": {
    "mandrill": {
      "APIkey": "",
      "from": {
        "name": "Altruist 🚀",
        "email": "[email protected]"
      },
      "subject": "Altruist",
      "template": "altruist-test"
    }
  }

Usage

POST /api/v1/actions/mandrill

curl -X POST -H "Content-Type: application/json" -d '{
  "email": "[email protected]",
  "vars": {
    "globals": [{
      "name": "Altruist"
    }],
    "targeted": [{
      "target": "[email protected]",
      "vars": [{
        "hello": "Hello mail,"
      }],
      "media": [{
        "name": 'media.ext',
        "content": "/path/to/my/media.ext"
      }]
    }]
  }
}' "http://localhost:6060/api/v1/actions/mandrill"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  </head>
  <body>
    {{#if hello}}<h2>{{hello}}</h2>{{/if}}
    <p>{{#if name}}{{name}} says{{/if}} hello !</p>
    <img src="{{cid:media}}" />
  </body>
</html>

more about Mandrill variables

Options

note: you can only attach one media

name type required description
email string array ×
vars.globals array array of object defining your Mandrill merge_vars (with key = name and value = content)
vars.targeted array
vars.targeted.target string address targeted
vars.targeted.vars array create/override merge_vars for the concerned address. Works the same as vars.global
media Object
media.name string name of the media that you will retrieve via cid:name
media.content string Can be either a path the media (in the filesystem or via http) or straight base64 datas
Examples
Video with thumbnail
let data = { 
  email: '[email protected]',
  vars: { globals: [{ share: 'http://path.to/url/of/user/page' }] }
  media: [
    { name: 'video', content: '/path/to/video.mp4' },
    { name: 'IMAGEID', content: '/path/to.thumbnail' }
  ]
}