我通过Mailgun发送了几百封电子邮件,如下:
// Send to Mailgun
$mailgunResult = $mgClient->sendMessage($domain, array(
'from' => $fromEmail,
'to' => $toListString,
'subject' => $emailSubject,
'text' => $textEmail,
'html' => $htmlEmail,
'recipient-variables' => $recipientJSON
));
这工作正常,但现在我想将自定义数据附加到每个电子邮件,例如我的每个电子邮件的ID等 . 文档显示如何将json数据添加到单个电子邮件,但我无法弄清楚如何使用Mailgun将我的数据列表与每个外发电子邮件匹配,就像收件人变量一样 .
有人做过吗?我使用Mailgun的门票让我指出了我已经引用过的文档 .
2 回答
我不确定我是否理解正确,因为你说你已经查看了文档 .
对我来说,它似乎在文档中得到了回答 . https://documentation.mailgun.com/user_manual.html#attaching-data-to-messages:
当你说“你的身份”时,你并不是说Mailgun称之为“标签”或“活动”,对吗?
HTH
您可以使用Mailgun 's template tags in your custom variables. I' m来通过我的网站唯一ID跟踪收件人 . 在API post有效内容中,使用
v:
样式添加变量,然后使用模板(%recipient.value%
)设置该变量的值 .一个示例JSON有效负载:
{ 'v:Recipient-Id': '%recipient.id%' 'recipient-variables:': { 'email@example.com': {'id': '123'}} }
然后在webhooks有效负载中,您将看到如下变量:
'Recipient-Id': '123'
我从Mailgun网站上有用的博客文章中找到了这个:http://blog.mailgun.com/closing-the-loop-between-your-customer-data-and-your-email-data/