View Source Bamboo.MandrillHelper (bamboo v2.3.1)
Functions for using features specific to Mandrill (e.g. tagging, merge vars, templates).
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.
Functions
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("merge_vars", [
%{
rcpt: "user1@example.com",
vars: [
%{
"name": "full_name",
"content": "User 1"
}
]
},
%{
rcpt: "user2@example.com",
vars: [
%{
"name": "full_name",
"content": "User 2"
}
]
}
])
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("track_opens", true)
|> put_param("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"])
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"}])