0

我有这个案子。我有一个向订阅者发送时事通讯的网站。电子邮件模板由 PHP 模板生成(例如 single-newsletter.php)

当用户在其电子邮件客户端中收到此时事通讯时,他/她可以阅读内容并查看以下链接:

a.) 在线查看时事通讯的链接(此在线内容仍使用 single-newsletter.php 模板)。

b.) 取消订阅时事通讯的链接。

电子邮件方面的一切都是完美的,所以这是按预期工作的。

我的问题是当用户点击“在线查看”链接时,时事通讯(现在在线查看,而不是在他/她的电子邮件客户端上查看)仍然有“在线查看”和取消订阅链接。我希望删除这两个链接。当用户在线查看时事通讯时,是否有一种简单的方法(没有我现有设置的副作用)可以将其删除?

电子邮件正文是通过对电子邮件模板执行 file_get_contents 生成的,然后将其放在 $mail_body 变量中。我正在考虑在 PHP 中使用这个条件:

if (empty($_SERVER['HTTP_USER_AGENT'])) {

//no user agent, this is the file_get_contents reading it
//render the View it online and subscription links
//So it will appear in the email body

} else {

//user agent detected, must be a user reading this online with his browser
//Don't show the view it online and unsubscription links

}

请让我知道这是否是一个好的解决方案,如果您有其他好的解决方案。请分享。谢谢。

感谢您的任何提示。

4

0 回答 0