mounting an array with php to p phpmailer

0

I'm trying to mount an array with the list of email addresses for phpmailer to send. But I'm having problems.

No error is displayed, php simply does not send the emails.

I am mounting the array like this:

     // Define os destinatário(s)
        $consulta = $mysqli->query("select email,nome from clientes where status=true");
        while ($resultado = mysqli_fetch_object($consulta)) {

            // Monta o array
            $destinatario[] = array($resultado->email => $resultado->nome);
        }

And send it like this:

foreach($destinatario as $email_cliente => $name){
    $mail->AddBCC($email_cliente, $name);
}

Can anyone help me? I think the problem is in the array assembly.

    
asked by anonymous 21.07.2016 / 21:01

1 answer

3

Try to do that Hugo:

    // Define os destinatário(s)
    $consulta = $mysqli->query("select email, nome from clientes where status=true");

    while ($resultado = mysqli_fetch_object($consulta)) {
        // Monta o array
        $destinatario[] = $resultado;
    }

    foreach($destinatario as $key => $value){
        $mail->AddBCC($value->email, $value->name);
    }
    
21.07.2016 / 21:16