dongxing8009 2018-03-26 13:52
浏览 100

使用Mailgun插件将标签添加到WordPress电子邮件

I have written a WordPress plugin that sends various transactional emails that I would like to track. Depending on the email, I'd like to add a different tag. I am currently using the Mailgun WordPress plugin, however, in the admin settings, the tags seem to apply to all emails sent from the site.

It seems I have to add an 'og:tag' somewhere, but I can't work out where.

$to =           'theiraddress@theirdomain.com';
$subject =      'Test';

$message =      'This is a test message';

$headers[] =    'From: My Website <myaddress@mydomain.com>';
$headers[] =    'Content-Type: text/html; charset=UTF-8';

wp_mail($to, $subject, $message, $headers)

The Mailgun library documentation says to add an array of tags to the 'og:tag' element of the message array, but the WordPress plugin doesn't seem to use the Mailgun library. Do I add the tag as a header? If so, what's the format?

  • 写回答

1条回答 默认 最新

  • duanji2772 2018-03-26 14:30
    关注

    Looking at https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-smtp I was able to see that the required header is 'X-Mailgun-Tag'.

    Adding the code below has worked:

    $headers[] =    'X-Mailgun-Tag: Test';
    

    Looking at the link above, to add multiple tags, add multiple lines:

    $headers[] =    'X-Mailgun-Tag: Test1';
    $headers[] =    'X-Mailgun-Tag: Test2';
    

    However, I haven't tested multiple tags.

    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用