emailer update fixed so it can now send to multiple recipients
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
use App\Models\EmailLog;
|
||||
use App\Models\EmailLogStatus;
|
||||
use App\Models\EmailTemplate;
|
||||
use App\Models\MailProfile;
|
||||
|
||||
class AutoMailDispatcher
|
||||
{
|
||||
@@ -95,6 +96,8 @@ public function maybeQueue(Activity $activity, bool $sendFlag = true): array
|
||||
$log->fill([
|
||||
'uuid' => (string) \Str::uuid(),
|
||||
'template_id' => $template->id,
|
||||
'mail_profile_id' => optional(MailProfile::query()->where('active', true)->orderBy('priority')->orderBy('id')->first())->id,
|
||||
'user_id' => auth()->id(),
|
||||
'to_email' => (string) ($recipients[0] ?? ''),
|
||||
'to_recipients' => $recipients,
|
||||
'subject' => (string) ($rendered['subject'] ?? $template->subject_template ?? ''),
|
||||
@@ -107,6 +110,10 @@ public function maybeQueue(Activity $activity, bool $sendFlag = true): array
|
||||
'client_case_id' => $clientCase?->id,
|
||||
'contract_id' => $contract?->id,
|
||||
]);
|
||||
// If multiple recipients, keep to_email null to avoid implying a single primary recipient
|
||||
if (count($recipients) > 1) {
|
||||
$log->to_email = null;
|
||||
}
|
||||
$log->save();
|
||||
|
||||
$log->body()->create([
|
||||
|
||||
Reference in New Issue
Block a user