From 8adfd5000e67fdfa1d9d77c2ee6cafab36ec2519 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 24 Nov 2026 11:35:13 +0530 Subject: [PATCH 1/2] Changed logic in ftp file process mail configuration --- app/Console/Commands/ProcessSftpFiles.php | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/ProcessSftpFiles.php b/app/Console/Commands/ProcessSftpFiles.php index 6d2d2bb5..2700ca0e 100644 --- a/app/Console/Commands/ProcessSftpFiles.php +++ b/app/Console/Commands/ProcessSftpFiles.php @@ -5,6 +5,7 @@ namespace App\Console\Commands; use App\Models\Machine; use App\Models\Plant; use App\Models\ProductionTemp; +use App\Models\AlertMailRule; use Illuminate\Console\Command; use App\Services\SftpFileService; use Filament\Facades\Filament; @@ -562,19 +563,27 @@ class ProcessSftpFiles extends Command } } + // Send error logs through email if (!empty($logMessages)) { - $emailContent = implode(PHP_EOL, $logMessages); + $alertRule = AlertMailRule::where('module', 'FtpLogs')->where('rule_name', 'FtpLogsMail')->first(); - Mail::raw('Please find attached machine error logs.', function ($message) use ($emailContent) { + if ($alertRule && !empty($alertRule->email)) { - $message->to(env('ERROR_LOG_MAIL')) - ->subject('Machine Error Logs') - ->attachData($emailContent, 'machine_errors.txt', [ - 'mime' => 'text/plain', - ]); - }); + $emailContent = implode(PHP_EOL, $logMessages); + + $toEmails = array_filter(array_map('trim', explode(',', $alertRule->email))); + + Mail::raw('Please find attached machine error logs.', function ($message) use ($emailContent, $toEmails) { + + $message->to($toEmails) + ->subject('Machine Error Logs') + ->attachData($emailContent, 'machine_errors.txt', [ + 'mime' => 'text/plain', + ]); + }); + } } $this->info('Production TXT file processing completed.'); -- 2.49.1 From 363f1339c44a3df5265eb674756dc078917064f2 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 24 Nov 2026 11:36:06 +0530 Subject: [PATCH 2/2] Added sftp file process trigger action --- app/Console/Commands/Scheduler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/Scheduler.php b/app/Console/Commands/Scheduler.php index 2fac3525..e55f42e8 100644 --- a/app/Console/Commands/Scheduler.php +++ b/app/Console/Commands/Scheduler.php @@ -42,7 +42,7 @@ class Scheduler extends Command $this->call('approval:trigger-mails'); $this->call('approval:laser-stop'); - // $this->call('sftp:process-files'); + $this->call('sftp:process-files'); // --- Production Rules --- $productionRules = AlertMailRule::where('module', 'ProductionQuantities') -- 2.49.1