Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Mandrill Merge Vars Working? #37

Open
marlongichie opened this issue May 7, 2016 · 4 comments
Open

Mandrill Merge Vars Working? #37

marlongichie opened this issue May 7, 2016 · 4 comments

Comments

@marlongichie
Copy link

Hello,

I can't seem to get "global merge vars" to work successfully, when sending a Mandrill Template.

The emails are sent, but the areas where the merged values should be, remains blank.

Here's a look at the code:

var message = {
        to: "john@gmail.com",
        mandrillOptions: {
            template_name: 'template1',
            "template_content": [
            ],
            "merge": true,
            "merge_language": "handlebars",
            "global_merge_vars": [{
                    "name": "fname",
                    "content": "John"
                },
                {
                    "name": "email",
                    "content": "john@gmail.com"
                }
            ]
        }};

In Mandrill, my vars are setup like so:

<!DOCTYPE html>
<html>
<head>
  <title></title>
</head>
<body>
  <div style="margin: 10%% 10%;text-align: justified;">
      <p>Hi {{fname}},</p>
      <p>You recently signed up for an Account using the email: {{email}}</p>
      <br>
      <p>If you did not sign up for an account with us, please ignore this email!</p>
  </div>
</body>
</html>

I should mention that the {{email}} field seems to work, with or without passing any merge vars when sending.

@grimor
Copy link

grimor commented May 12, 2016

You need to pass

"merge": true,
"merge_language": "handlebars",
"global_merge_vars": [{
        "name": "fname",
        "content": "John"
    },
    {
        "name": "email",
        "content": "john@gmail.com"
    }
]

in message property (as in Mandril API docs)

var message = {
    to: "john@gmail.com",
    mandrillOptions: {
        template_name: 'template1',
        template_content: [
        ],
        message: {
            "merge": true,
            "merge_language": "handlebars",
            "global_merge_vars": [{
                    "name": "fname",
                    "content": "John"
                },
                {
                    "name": "email",
                    "content": "john@gmail.com"
                }
            ]
        }
    }
}};

@arizawan
Copy link

You need to pass

"merge": true,
"merge_language": "handlebars",
"global_merge_vars": [{
        "name": "fname",
        "content": "John"
    },
    {
        "name": "email",
        "content": "john@gmail.com"
    }
]

in message property (as in Mandril API docs)

var message = {
    to: "john@gmail.com",
    mandrillOptions: {
        template_name: 'template1',
        template_content: [
        ],
        message: {
            "merge": true,
            "merge_language": "handlebars",
            "global_merge_vars": [{
                    "name": "fname",
                    "content": "John"
                },
                {
                    "name": "email",
                    "content": "john@gmail.com"
                }
            ]
        }
    }
}};

You just saved my life. Thanks.

@OmarKhattab
Copy link

You need to pass

"merge": true,
"merge_language": "handlebars",
"global_merge_vars": [{
        "name": "fname",
        "content": "John"
    },
    {
        "name": "email",
        "content": "john@gmail.com"
    }
]

in message property (as in Mandril API docs)

var message = {
    to: "john@gmail.com",
    mandrillOptions: {
        template_name: 'template1',
        template_content: [
        ],
        message: {
            "merge": true,
            "merge_language": "handlebars",
            "global_merge_vars": [{
                    "name": "fname",
                    "content": "John"
                },
                {
                    "name": "email",
                    "content": "john@gmail.com"
                }
            ]
        }
    }
}};

Worked for me

@patelashish16
Copy link

must pass this paramater

 merge: true,
 merge_language: "handlebars",

work for me

mandrill('/messages/send-template', {
message: {
to: recipients,
from_email: 'test@gmail.com',
subject: "comment subject",
merge: true,
merge_language: "handlebars",
global_merge_vars: [
{
"name": "site_link",
"content": "here"
}
]
},
preserve_recipients: true,
template_name: "test-comment-template",
template_content: [
{
"name": "sender_first_name",
"content": "sadasd"
},
{
"name": "job_name",
"content": "jobName"
}
]
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants