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
This commit is contained in:
@@ -209,6 +209,27 @@ function getEFTDetails($eft_id) {
|
|||||||
|
|
||||||
function sendPOP($fullname, $eft_id, $amount, $description)
|
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 = [
|
$message = [
|
||||||
'Messages' => [
|
'Messages' => [
|
||||||
[
|
[
|
||||||
@@ -216,20 +237,7 @@ function sendPOP($fullname, $eft_id, $amount, $description)
|
|||||||
'Email' => $_ENV['MAILJET_FROM_EMAIL'],
|
'Email' => $_ENV['MAILJET_FROM_EMAIL'],
|
||||||
'Name' => $_ENV['MAILJET_FROM_NAME'] . ' Web Admin'
|
'Name' => $_ENV['MAILJET_FROM_NAME'] . ' Web Admin'
|
||||||
],
|
],
|
||||||
'To' => [
|
'To' => $toAddresses,
|
||||||
[
|
|
||||||
'Email' => 'chrispintoza@gmail.com',
|
|
||||||
'Name' => 'Chris Pinto'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'Email' => $_ENV['MAILJET_FROM_EMAIL'],
|
|
||||||
'Name' => 'Jacqui Boshoff'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'Email' => 'louiseb@global.co.za',
|
|
||||||
'Name' => 'Louise Blignault'
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'TemplateID' => 7054062,
|
'TemplateID' => 7054062,
|
||||||
'TemplateLanguage' => true,
|
'TemplateLanguage' => true,
|
||||||
'Subject' => "4WDCSA - Proof of Payment Received",
|
'Subject' => "4WDCSA - Proof of Payment Received",
|
||||||
|
|||||||
Reference in New Issue
Block a user