My PHPMailer seems to work, but loops through the mailer only 6 times instead of 24 times. if loop used without mailer, it does return 24 addresses. I'm connected to an internal network with access from outside. can anyone clear up what is going on. ($link -> close()) is done at a later stage. also the 24 emails sent two 2 different email accounts(for testing purposes), both receive 3 emails from this phpMailer. found many posts regarding phpMailer, I haven't encountered this one so far.
if ($result = $link->query("SELECT Adres FROM Emails")) {
//Alle variabelen voor de mail
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->SMTPKeepAlive = true;
$mail->Host = 'smtp-mail.outlook.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '**********@outlook.com'; // SMTP username
$mail->Password = '**********'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('**********@outlook.com');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'APP';
$mail->Body = 'is this working??';
$mail->AltBody = 'is this working??';
while($row = mysqli_fetch_row($result)) {
$variable = $row[0];
$mail->addAddress($variable);
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
$mail->ClearAllRecipients( );
}
$result->close();
}