Are you sure you're getting results from your query?
Your query/code doesn't make a whole lot of sense anyway. Your querying for records where SubRenew = 30, and the only data you're using as a result of that query is the SubRenew column which is guaranteed to be 30 at that point so why bother?
Look at the cleaned up block of your code loop;
foreach ($result as $row)
{
$mail->addAddress('[email protected]', 'James Coates');
$mail->Body("This subscription is expiring on" . $row['subRenew']);
$mail->send(); // DROP THIS LINE!!!
if (!$mail->Send())
echo 'Something went wrong';
else
echo 'Mail sent to somebody Complete.';
//Clear all addresses and attachments for the next iteration
$mail->clearAddresses();
$mail->clearAttachments();
}
As you can see you were doing the send (?) twice although function names are different.
Secondly - where are you using the results of your query loop? I see a static address but nothing from your loop.
The purpose of that is to change a date string (eg '19-04-2022') which is in %d-%m-%Y format to a correct DATE format.
RTFM - https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_str-to-date
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.