Add [TEST] and [CRON] labels to distinguish execution source
All checks were successful
Deploy Production Email Reports (Unified) / deploy (push) Successful in 1m0s

This commit is contained in:
Frank John Begornia
2026-01-04 13:56:14 +08:00
parent 2eeec4377f
commit 2a857d2bfa

View File

@@ -8,6 +8,7 @@ $dateTimeToday = date("Y-m-d H:i:s");
// Determine which brand to process
$brand = getenv('BRAND') ?: 'crew'; // 'crew' or 'merchbay'
$is_test = getenv('TEST_EMAIL') === 'true';
// Brand-specific configuration
$config = [
@@ -149,14 +150,17 @@ if($result > 0){
$mail->IsHTML(true);
if(!$mail->Send()){
$msg = $dateTimeToday . "\t\t\t{$cfg['log_prefix']} Mailer Error: " . $mail->ErrorInfo . "\n";
$test_label = $is_test ? ' [TEST]' : ' [CRON]';
$msg = $dateTimeToday . "\t\t\t{$cfg['log_prefix']}{$test_label} Mailer Error: " . $mail->ErrorInfo . "\n";
file_put_contents('email.log', print_r($msg, true), FILE_APPEND);
} else {
$msg = $dateTimeToday . "\t\t\t{$cfg['log_prefix']} successfully sent ({$result} orders)\n";
$test_label = $is_test ? ' [TEST]' : ' [CRON]';
$msg = $dateTimeToday . "\t\t\t{$cfg['log_prefix']}{$test_label} successfully sent ({$result} orders)\n";
file_put_contents('email.log', print_r($msg, true), FILE_APPEND);
}
} else {
$msg = $dateTimeToday . "\t\t\t{$cfg['log_prefix']} No order for today\n";
$test_label = $is_test ? ' [TEST]' : ' [CRON]';
$msg = $dateTimeToday . "\t\t\t{$cfg['log_prefix']}{$test_label} No order for today\n";
file_put_contents('email.log', print_r($msg, true), FILE_APPEND);
}