问题
I have a working mail script and there are times that the sending times out because our internet connection is not stable. I was advised to mark sent messages to the mails after it has been sent. I've tried this script but so far it only updates the first email it sends to and not the rest.
if(isset($row_get_sender['setfrom_email'])) {
do {
$mail->AddAddress($row_get_recipient['email']);
$mail->Send();
$update_recipient;
$mail->ClearAddresses();
} while($row_get_recipient = mysql_fetch_assoc($get_recipient));
}
and my queries:
mysql_select_db($database_mail, $mail);
$query_get_recipient = "SELECT * FROM `to` WHERE `mailSent` = '0'";
$get_recipient = mysql_query($query_get_recipient, $mail) or die(mysql_error());
$row_get_recipient = mysql_fetch_assoc($get_recipient);
$totalRows_get_recipient = mysql_num_rows($get_recipient);
$query_update_recipient = "UPDATE `to` SET `mailSent` = '1' WHERE `email` = '$row_get_recipient[email]'";
$update_recipient=mysql_query($query_update_recipient,$mail) or die (mysql_error());
来源:https://stackoverflow.com/questions/13619682/update-rows-in-a-while-loop-php