dimoss
Well-Known Member
Hi
i am using the following php script for a scheduled task to send emails:
Settings in the schedule tasks are below:
I have also set the cron job in the Server to run on specific date / time:
wget https://xxxxxxxxxxxx/index.php?fabrik_cron=xxxxx
However the emails are not sent and i dont receive any email notification.
Any help?
Thanks,
i am using the following php script for a scheduled task to send emails:
PHP:
use Joomla\CMS\Factory;
use Fabrik\Helpers\FabrikWorker;
$config = Factory::getConfig();
$db = \Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
$queryString = "SELECT player_id, name, assoc, email FROM vw_expired_passports WHERE assoc = 'XXX'";
$db->setQuery($queryString);
$rows = $db->loadAssocList();
$successCount = 0;
$failureCount = 0;
foreach ($rows as $row) {
$pid = $row['player_id'];
$playerName = $row['name'];
$playerAssoc = $row['assoc'];
$playerEmail = $row['email'];
$subject = "Expired Passport for Player: " . $playerName;
$msg = "Hello $playerAssoc,\nThis is a reminder to update the passport of the player: $playerName. Please do so through the link.";
$res = FabrikWorker::sendMail(
$config->get('mailfrom'),
$config->get('fromname'),
$playerEmail,
$subject,
$msg
);
if ($res) {
$successCount++;
} else {
$failureCount++;
}
}
// Send email notification
$notificationSubject = "Email Sending Summary";
$notificationMessage = "Emails sent successfully: $successCount\nEmails failed: $failureCount";
$notificationRes = FabrikWorker::sendMail(
$config->get('mailfrom'),
$config->get('fromname'),
"xxx@xxx.com",
$notificationSubject,
$notificationMessage
);
if ($notificationRes) {
echo "Notification email sent successfully.<br>";
} else {
echo "Failed to send notification email.<br>";
}
Settings in the schedule tasks are below:
I have also set the cron job in the Server to run on specific date / time:
wget https://xxxxxxxxxxxx/index.php?fabrik_cron=xxxxx
However the emails are not sent and i dont receive any email notification.
Any help?
Thanks,