How to send PHP mailer to multiple email addresses received via MySQL query

前端 未结 2 1321
北海茫月
北海茫月 2021-01-14 07:26

I run a MySQL query to get firstname, lastname and email from a table where \'notify\' is set to YES, like this below. And in the while loop, I create all the info which I

2条回答
  •  无人共我
    2021-01-14 08:21

    Your array isn't well constructed, use the following:

    while ($row = mysqli_fetch_array($getnotify)) {
         $notifyemailscontent[$row['email']] =  "{$row['firstname']}  {$row['lastname']}";
    }
    

    Then, inside the phpmailer block:

    foreach($notifyemailscontent as $email => $name)
    {
       $mail->AddCC($email, $name);
    }
    

提交回复
热议问题