对于我网站的电子邮件更新功能,我不希望收到电子邮件的所有用户都看到所有其他成员的电子邮件地址
如何禁用此功能/关闭此功能?
我的代码:
if($query -> execute()) {
if($sendmsg == 1) {
$emailquery = $db->prepare("SELECT email FROM tbl_users WHERE emailupdates = 1");
$emailquery -> execute();
$elist = "";
while($mail = $emailquery->fetch(PDO::FETCH_OBJ)) {
$elist .= $mail->email . ", ";
}
$emails = substr($elist, 0, -2);
$link = "http://xxxxx.nl/kalenderdetail/" . $id;
$to = $emails;
$subject = "Nieuwe wedstrijd toegevoegd aan kalender xxxxx.nl";
$message .= "Beste lid van xxxx.nl,\n\n";
$message .= "Er is zojuist een nieuwe wedstrijd toegevoegd aan de website.\n";
$message .= "Titel van de wedstrijd: " . $titel ."\n";
$message .= "Locatie: " . $locatie . "\n";
$message .= "Bekijk het hele kalenderitem: ". $link . "\n\n";
$message .= "Met sportieve groeten,\n";
$message .= "xxxxxx\n";
$from = "info@xxxxx.nl";
$headers = "From: $from";
if(mail($to,$subject,$message,$headers)) {
$msg = "Edit en mail succesvol";
header("location: xxxxxxxx?msg=" . $msg);
}
答案 0 :(得分:1)
您可以将代码放在while循环中发送电子邮件,因此,不是一封电子邮件发送到多个地址,而是在一个地址上发送多封电子邮件,但这可能会导致垃圾邮件问题。
或者你可以使用BCC(盲碳复制)See here
与问题无关的旁注,我个人发现你使用的有点凌乱的2字符方法。你可以通过这种方式获得相同的结果。
$elist = array();
while($mail = $emailquery->fetch(PDO::FETCH_OBJ)) {
$elist[] = $mail->email;
}
$emails = implode(', ', $elist);
如果您更改分隔符(,
)的好处是,您也不需要编辑substr方法,但正如我所说,这只是我对此的个人意见。