【发布时间】:2016-05-30 11:56:49
【问题描述】:
我有一个时事通讯系统,所以当我想向所有订阅者发送消息时,我会通过一个名为 post-processing.php 的 php 文件发送它。
这是我的post-processing.php 代码:
$count=$dbo->prepare("select * from sw_post where post_id=:post_id");
$count->bindParam(":post_id",$post_id,PDO::PARAM_INT,4);
if($count->execute()){
echo " Success <br>";
$row = $count->fetch(PDO::FETCH_OBJ);
$sub=$row->sub;
$post=$row->post;
} else {
echo "Database Error ..";
print_r($count->errorInfo());
exit;
}
/////////////////////////
$dtl="";
$dtl .=$post. "\n\n";
@$headers.="Reply-to: $from_email\n";
$headers .= "From: $from_email\n";
$headers .= "Errors-to: $from_email\n";
//$headers = "Content-Type: text/html; charset=iso-8859-1\n".$headers;
// Above line is required to send HTML email
$sql="select email_id, email from sw_email where status='A'";
$i=0;
foreach ($dbo->query($sql) as $row) {
$url=$base_url."unsubscribe.php?email_id=$row[email_id]&email=$row[email]&todo=delete";
$dtl .= "Click on the URL to unsubscribe $url ";
假设我有三个订阅者,当我收到电子邮件时,我会得到以下结果:
Click on the URL to unsubscribe: http://#.com/unsubscribe.php?email_id=1&email=example1@email.com&todo=delete
Click on the URL to unsubscribe: http://#.com/unsubscribe.php?email_id=2&email=example2@email.com&todo=delete
Click on the URL to unsubscribe: http://#.com/unsubscribe.php?email_id=3&email=example3@email.com&todo=delete
但我想要的结果只有:
Click on the URL to unsubscribe: http://#.com/unsubscribe.php?email_id=1&email=example@email.com&todo=delete
我不希望处方者收到取消订阅我所有订阅者的链接。我该如何解决这个问题?
【问题讨论】:
标签: php html email unsubscribe