使用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个回答



查看 https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-smtp 我能看到所需的标题是'X- Mailgun-Tag'。</ p>

添加以下代码有效:</ p>

  $ headers [] ='X-Mailgun-Tag:Test  '; 
</ code> </ pre>

查看上面的链接,添加多个标签,添加多行:</ p>

  $ headers  [] ='X-Mailgun-Tag:Test1'; 
$ headers [] ='X-Mailgun-Tag:Test2';
</ code> </ pre>

但是,我 尚未测试多个标签。</ p>
</ div>

展开原文

原文

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.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐