简体   繁体   English

PHP不显示电子邮件中的电子邮件地址

[英]php not show email addresses in email

For the email updates function of my website I don't want all the users which receive the email to see all other members their email addresses 对于我网站的电子邮件更新功能,我不希望所有接收电子邮件的用户看到所有其他成员的电子邮件地址

How can I disable this/turn this off? 如何禁用/关闭此功能?

My code: 我的代码:

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);
    }

You could either put the code to send the email within the while loop, so rather than one email to multiple addresses, you send multiple emails on one address, but this could lead to spam issues. 您可以将代码放置在while循环内发送电子邮件,因此,不是将一封电子邮件发送到多个地址,而是在一个地址上发送多个电子邮件,但这可能会导致垃圾邮件问题。

Alternatively you could use BCC (Blind Carbon Copy) See here 另外,您可以使用BCC(密件抄送) 看这里

A side note not related to the question, I personally find the chopping 2 characters method you use a little messy. 与问题无关的旁注,我个人觉得您使用的2字符切碎方法有点混乱。 You could achieve the same result this way. 您可以通过这种方式获得相同的结果。

$elist = array();
while($mail = $emailquery->fetch(PDO::FETCH_OBJ)) {
    $elist[] = $mail->email;
}


$emails = implode(', ', $elist);

The benefit being if you change the delimiter ( , ), you don't need to edit the substr method aswell, but as I say this is just my personal opinion on this. (即如果你改变了分隔符的好处, ),你不需要编辑SUBSTR方法藏汉,但就像我说的,这只是我对这个个人的意见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM