PHPMailer and foreach

0

I have refactored the email from my site.

Among the new features, you can now send a message to more than one e-mail.

I have this select that searches which emails are from the recipients:

<?php
/****** E-mails dos destinatários ******/
$sql_email_dest = mysqli_query($config, "SELECT email FROM tb_email_home_email WHERE id_item = '1'") or die(mysqli_error($config));

if(@mysqli_num_rows($sql_email_dest) <= '0'){
    echo "";
}else{
    while($r_sql_email_dest = mysqli_fetch_array($sql_email_dest)){
        $email_email_home_sel[] = $r_sql_email_dest[0];
    }
}   
/****** E-mails dos destinatários ******/   

?>

And in PHPMailer, this foreach to send:

<?php
foreach($email_email_home_sel as $email_contato){
    $mail->AddAddress($email_contato);            // E-mail do destinatário
}   
?>

It's simple, but I've tried it in many ways ...

If I put it the old way, with an email (not in foreach) it works.

But the way above, no chance.

Has anyone seen a similar case?

Do you have any ideas?

    
asked by anonymous 05.04.2018 / 15:15

0 answers