smtp - How to use X-MC-MergeVars for handlebars -


i new mandrill , trying setup mail using handlebars , smtp. template looks -

<span> {{username}}, </span> welcome ...... 

this mailer.js looks (running on node.js)

var mailer   = require("mailer")   , username = "**@***.com"   , password = "*********";  mailer.send(   {host:           "smtp.mandrillapp.com",    port:           25,    to:             "**@gmail.com",    from:           "**@gmail.com",    subject:        "mail using mandrill!",    authentication: "login",    username:       "**@**.com",    password:       "********",    headers: {       "x-mc-track": "clicks",       "x-mc-autotext": true,       "x-mc-template": "newsfeed",       "x-mc-mergevars": {"username": "pranav"},       "x-mc-mergelanguage": "handlebars"    }   }, function(err, result){     if(err){       console.log(err);     }   } ); 

i receive mail, username not replaced username value passed x-mc-mergevars , replaced empty string.

am missing something?

thanks,

all of mail headers need strings; you're passing javascript object mergevars.

try using json.stringify convert object string header:

  "x-mc-mergevars": json.stringify( {"username": "pranav"} ), 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -