将数据添加到MailGun群发电子邮件

Chr*_*out 3 php mailgun

我通过Mailgun发送了几百封电子邮件,如下所示:

// Send to Mailgun
$mailgunResult = $mgClient->sendMessage($domain, array(
  'from'    => $fromEmail,
  'to'      => $toListString,
  'subject' => $emailSubject,
  'text'    => $textEmail,
  'html'    => $htmlEmail,
  'recipient-variables' => $recipientJSON
));
Run Code Online (Sandbox Code Playgroud)

这工作正常,但现在我想将自定义数据附加到每个电子邮件,例如我的每个电子邮件的ID等.文档显示如何将json数据添加到单个电子邮件,但我无法弄清楚如何使用Mailgun将我的数据列表与每个外发电子邮件匹配,就像收件人变量一样.

有人做过吗?我的Mailgun门票让我指出了我已经引用过的文档.

k0n*_*0nG 6

您可以在自定义变量中使用Mailgun的模板标记.我正在使用它来通过我的网站唯一ID来跟踪收件人.在API post有效负载中使用v:样式添加变量,然后使用templating(%recipient.value%)设置该变量的值.

一个示例JSON有效负载:

'Recipient-Id': '123'

然后在webhooks有效负载中,您将看到如下变量:

v:

我从Mailgun网站上有用的博客文章中找到了这个:http://blog.mailgun.com/closing-the-loop-between-your-customer-data-and-your-email-data/