parse.com - mc:edit do not work in Mailchimp template with Mandrill Javascript API -
i'm trying send emails through mandrill api mailchimp templates. doing in cloud code parse.com, see here https://www.parse.com/docs/cloud_modules_guide#mandrill. emails sent fine, however, mc:edit fields never updated. content in template now:
<span mc:edit="ship_id">ship_id</span>
this phone call in javascript looks like, hope sees mistake. i'm running in parse.com cloud code if makes difference. lot!
var mandrill = require('mandrill'); mandrill.initialize('api-key'); mandrill.sendtemplate({ template_name: "drip campaign", template_content: [{ name: "ship_id", content:"test test" }], message: { text: "hi", subject: "you have new mail", from_email: "info@example.com", from_name: "thomas", to: [ { email: "answer@example.com", name: "fred" } ], "headers": { "reply-to": "answer@example.com" }, "important": false, "track_opens": true, "track_clicks": true, }, async: true },{ success: function(httpresponse) { response.success("email sent!"); }, error: function(httpresponse) { console.error(httpresponse); response.error("uh oh, went wrong"); } }); }
as far understand question want send e-mail @ same time want dynamically edit mail service content. have used, can via mandrill api. suggest utilize js files downloadable in link;
https://github.com/jlainog/parse-mandrill-sendtemplate
from js file in github account, can dynamically edit mail service content(must in template) via using tag mc:edit.
for case working re-create of code below;
parse.cloud.define("sendmail", function(request, response) { var mandrill = require('cloud/mandrillsend.js'); var sentto = //mail address sent var subject = //mail subject var fromemail = //from email var fromname = //from name var senttoname = //parameters request var fullname = //full name mandrill.initialize('your mandrill api key'); mandrill.sendtemplate({ template_name: "mandril template", template_content: [ { name: "nameheader", content: senttoname, }, { name: "mail", content: sentto, }, ], "key": "your mandrill api key", message: { subject: subject, from_email: fromemail, from_name: fromname, to: [{ email: sentto, name: fullname }], important: true }, async: false }, { success: function (httpresponse) { console.log(httpresponse); response.success("email sent!"); }, error: function (httpresponse) { console.error(httpresponse); response.error("uh oh, went wrong"); } }); });
for example, in mandrdil template there span id;
<span mc:edit="mail"> test@gmail.com</span>
hope helps. regards.
javascript parse.com mailchimp mandrill
No comments:
Post a Comment