Search code examples
phpjsonemailmandrillmailmerge

Mandrill: merge_vars not working


I'm working on sending diffenrent links to user emails via Mandrill 'merge_vars' but it is not working. Relevant parts from API log:

"message": {
    "preserve_recipients": false,
    "auto_text": false,
    "auto_html": false,
    "to": [
        {
            "email": "kajacx10@gmail.com"
        }
    ],
    "html": "... link: *|REFUSELINK|* ...",
    "text": "... link: *|REFUSELINK|* ...",
    "merge": true,
    "merge_language": "mailchimp",
    "merge_vars": [
        {
            "recipient": "kajacx10@gmail.com",
            "vars": [
                {
                    "name": "refuselink",
                    "content": "http://myLink.com"
                }
            ]
        }
    ]
},
"key": "myKey"

I receive the email correctly, but I see the original *|REFUSELINK|* instead of the desired replacement. Any idea what I'm doing wrong?


Solution

  • Ups, it's rcpt, not recipient:

    "merge_vars": [
        {
            "rcpt": "kajacx10@gmail.com", /* <-- here */
            "vars": [
                {
                    "name": "refuselink",
                    "content": "http://myLink.com"
                }
            ]
        }
    ]