I have passed dynamic content to the body of the email. But looking at the API docs the subject params only accepts a string and not an array.
Is there a way to pass a dynamic subject? I would like to pass the name of the recipient in the subject
I have the following right now:
m = Mandrill::API.new ENV['MANDRILL_APIKEY']
message = {
:subject=> template.subject,
:from_name=> template.name,
:from_email=> template.from + "@" + email_domain,
:to=>mails,
:global_merge_vars=> [
{ :name => 'IMAGE', :content => image_tag},
],
:html=>email_template,
:preserve_recipients => false,
:merge_vars => variables,
}
It seems that Mandrill reads merge variables in the subject as well. So it is as simple as adding
*|SOME_VAR|*
in your subject text and then passing it as a parameter in themerge_vars
.More details here.