php - wp_mail 退订链接
问题描述
我正在使用 wp_mail 功能向我的订阅者发送时事通讯模板。我只是从我的数据库中检索我的订阅者列表并将其作为 $to 的数组传递给 wp_mail 函数。现在的问题是,我想在我的电子邮件中添加取消订阅链接。我想要实现的只是一种在我的取消订阅的超链接中添加收件人的电子邮件地址作为参数的方法,以便我可以将其用于取消订阅。即 www.mysiteurl.com/?user_email=useremail@domain.in
//php code
ob_start();
//including newsletter template
include '/newsletter-template.php';
$message = ob_get_contents();
ob_end_clean();
//adding filter to allow <html> tags in message body
add_filter( 'wp_mail_content_type', 'newsletter_content_type' );
@wp_mail( $subscriberListArray, 'Testing Newsletter', $message, 'From: myWebsite <newsletter@myWebsite.com>' );
//removing <html> tags filter once mail is sent
remove_filter( 'wp_mail_content_type', 'newsletter_content_type' );
//html part
<div>
<a href="www.mysiteurl.com/?user_email={dynamic_value}">unsubscribe</a>
</div>
上面的代码工作正常,但我想在我的模板文件中插入当前订阅者的电子邮件。有什么办法吗?谢谢你。
解决方案
推荐阅读
- unit-testing - 如何在 Sinon 中模拟内部函数?
- zsh - 使用 tmux 时转义 zsh vi 模式的“插入模式”
- api - 在机器人框架中是否可以通过 api 在另一个关键字中定义一组关键字
- php - PHP / Yii2 在注册前检查数据库中的至少 1 个位置是否有足够的时间空闲
- github - 使用 GitHub 的 CI 的图形历史测试持续时间
- javascript - 表格tbody垂直滚动条在滚动时闪烁
- php - Wordpress:如何挂钩 get_the_post_thumbnail_url() 函数
- reactjs - 从 React 上下文 API 的列表中删除记录后无法设置道具值
- android - 没有网络时打开另一个活动
- css - 使用 Knockoutjs 获取设置值属性