bamboo v1.3.0 Bamboo.MandrillHelper View Source

Functions for using features specific to Mandrill (e.g. tagging, merge vars, templates).

Link to this section Summary

Functions

Set merge_vars that are used by Mandrill.

Put extra message parameters that are used by Mandrill.

Set a single tag or multiple tags for an email.

Send emails using Mandrill's template API.

Link to this section Functions

Link to this function

put_merge_vars(email, enumerable, fun) View Source

Set merge_vars that are used by Mandrill.

Example

email
|> put_merge_vars(users, fn(user) -> %{first_name: user.first_name} end)

A convenience function for:

email
|> put_param(email, "merge_vars", [
  %{
    rcpt: "user1@example.com",
    vars: [
      %{
        "name": "full_name",
        "content": "User 1"
      }
    ]
  },
  %{
    rcpt: "user2@example.com",
    vars: [
      %{
        "name": "full_name",
        "content": "User 2"
      }
    ]
  }
])
Link to this function

put_param(email, key, value) View Source

Put extra message parameters that are used by Mandrill.

Parameters set with this function are sent to Mandrill when used along with the Bamboo.MandrillAdapter. You can set things like important, merge_vars, and whatever else you need that the Mandrill API supports.

Example

email
|> put_param(email, "track_opens", true)
|> put_param(email, "merge_vars", [
  %{
    rcpt: "recipient.email@example.com",
    vars: [
      %{
        "name": "first_name",
        "content": "John Doe"
      }
    ]
  }
])

Set a single tag or multiple tags for an email.

A convenience function for put_param(email, "tags", ["my-tag"])

Example

tag(email, "welcome-email")
tag(email, ["welcome-email", "marketing"])
Link to this function

template(email, template_name, template_content \\ []) View Source

Send emails using Mandrill's template API.

Setup Mandrill to send using a named template with template content. Use this in conjunction with merge vars to offload template rendering to Mandrill. The template name specified here must match the template name stored in Mandrill. Mandrill's API docs for this can be found here.

Example

template(email, "welcome")
template(email, "welcome", [%{"name" => "Name", "content" => "John"}])