phpmailer показывает всех получателей по почте - PullRequest
0 голосов
/ 19 апреля 2020

phpmailer показывает всех получателей в почте, он показывает электронные письма всех пользователей в каждом письме в разделе «до» почты see screenshot

https://i.stack.imgur.com/2zRag.png

    $mail = new PHPMailer;
    $mail->isSMTP();
    $mail->SMTPDebug = 2;
    $mail->Host = 'smtp.hostinger.com';
    $mail->Port = 587;
    $mail->SMTPAuth = true;
    $mail->Username = 'filip@joint2purchase.com';
    $mail->Password = 'filip321';
    $mail->setFrom('filip@joint2purchase.com', 'Client Filip');

    //get the administrators emails
    $stmt = $db->prepare('SELECT USERNAME,EMAIL,TYPE FROM MEMBERS WHERE TYPE = :T LIMIT 100');
    $stmt->execute(array(':T' => 'ADMINISTRATOR'));

    //for each email add a recipient
    while($row3 = $stmt->fetch()){
        $toname = $row3['USERNAME'];
        $tomail = $row3['EMAIL'];
        $mail->addAddress($tomail, $toname);
    }

    //build the rest email (html, attaches, etc)
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    $mail->addAttachment('test.txt');
    if (!$mail->send()) {
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'The email message was sent.';
    }```
...