From a3403bf503e9996d0d5f9884d77d2d82ffd51445 Mon Sep 17 00:00:00 2001 From: twotalesanimation <80506065+twotalesanimation@users.noreply.github.com> Date: Thu, 4 Dec 2025 16:14:16 +0200 Subject: [PATCH] Fix: Move POP notification email addresses to .env configuration - Updated sendPOP() function to read recipient emails from POP_NOTIFICATION_EMAILS env variable - Supports comma-separated email list for flexibility - Allows dev and live servers to have different notification recipients - Falls back to info@4wdcsa.co.za if no env variable configured --- src/config/functions.php | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/config/functions.php b/src/config/functions.php index cfa1ef7e..9c71a42d 100644 --- a/src/config/functions.php +++ b/src/config/functions.php @@ -209,6 +209,27 @@ function getEFTDetails($eft_id) { function sendPOP($fullname, $eft_id, $amount, $description) { + // Build the 'To' array from environment variables + $toAddresses = []; + + // Parse comma-separated email addresses from .env + $emailsEnv = $_ENV['POP_NOTIFICATION_EMAILS'] ?? ''; + if (!empty($emailsEnv)) { + $emails = array_map('trim', explode(',', $emailsEnv)); + foreach ($emails as $email) { + if (!empty($email)) { + $toAddresses[] = ['Email' => $email]; + } + } + } + + // Fallback to default if no emails configured + if (empty($toAddresses)) { + $toAddresses = [ + ['Email' => 'info@4wdcsa.co.za'] + ]; + } + $message = [ 'Messages' => [ [ @@ -216,20 +237,7 @@ function sendPOP($fullname, $eft_id, $amount, $description) 'Email' => $_ENV['MAILJET_FROM_EMAIL'], 'Name' => $_ENV['MAILJET_FROM_NAME'] . ' Web Admin' ], - 'To' => [ - [ - 'Email' => 'chrispintoza@gmail.com', - 'Name' => 'Chris Pinto' - ], - [ - 'Email' => $_ENV['MAILJET_FROM_EMAIL'], - 'Name' => 'Jacqui Boshoff' - ], - [ - 'Email' => 'louiseb@global.co.za', - 'Name' => 'Louise Blignault' - ] - ], + 'To' => $toAddresses, 'TemplateID' => 7054062, 'TemplateLanguage' => true, 'Subject' => "4WDCSA - Proof of Payment Received",