Question

I have a Rails 4 application which sends emails using Mandrill. I am trying to detect weather a mail was opened or bounced, so I am using webhooks for this. I successfully receive the webhooks, but I can't tell which of them identify a particular email from my database.

I've tried using this

  def send_message(email)

    mail( from: ...,
          to: ...,
          subject: ...)

    headers["X-MC-AutoHtml"] = "true"
    headers["X-MC-Track"] = "opens"
    headers['X-MC-MergeVars'] = { "id" => some_id }.to_json
  end

but I'm not sure if I'm supposed to receive the X-MC-MergeVars back ( this is what I've understand from the docs)

Unfortunately, it's not working.

Do you have any ideas or an alternative solution? Thanks

Was it helpful?

Solution

I've figured it out by myself.

This is the line that needs to be there

headers['X-MC-Metadata'] = { "user_id" => user.id}.to_json

Here are the further details: http://help.mandrill.com/entries/21786413-Using-Custom-Message-Metadata

Hope it helps someone since it cost me several hours.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top