Hi Kicken,
I hope your well.
Thanks for you reply. I have re writen the code with clearAddresses() command I am no longer getting any errors but all I get is blank screen.
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
/**
* This example shows how to send a message to a whole list of recipients efficiently.
*/
//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;
error_reporting(E_STRICT | E_ALL);
date_default_timezone_set('Etc/UTC');
require 'scripts/vendor/autoload.php';
//Passing `true` enables PHPMailer exceptions
$mail = new PHPMailer(true);
$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'smtp.office365.com';
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true; //SMTP connection will not close after each email sent, reduces SMTP overhead
$mail->Port = 587;
$mail->Username = '
[email protected]';
$mail->Password = '*****';
$mail->setFrom('
[email protected]', 'JHE Reports');
$mail->Subject = 'Expiring Subscription for Customer';
//Connect to the database and select the recipients from your mailing list that have not yet been sent to
//You'll need to alter this to match your database
$mysql = mysqli_connect('localhost', 'root', '****');
mysqli_select_db($mysql, 'license_manager');
$result = mysqli_query($mysql, 'SELECT * FROM customersubscriptions WHERE SubRenew = 30');
foreach ($result as $row) {
$mail->addAddress('
[email protected]', 'James Coates');
$mail->Body("This subscription is expiring on" . $row['subRenew']);
$mail->send();
if (!$mail->Send()) {
echo 'Something went wrong';
} else {
echo 'Complete.';
}
//Clear all addresses and attachments for the next iteration
$mail->clearAddresses();
$mail->clearAttachments();
}
Any Ideas?
Many Thanks
Coatse