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 Pwm双极模式H桥驱动控制电机
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题