From ebb81aff68c7a445901d6af223a448936941a61d Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Fri, 28 Mar 2025 19:09:36 +0100 Subject: [PATCH] refactor(email): allow custom email recipients in email sending logic --- app/Notifications/Channels/EmailChannel.php | 7 ++++++- resources/views/livewire/notifications/email.blade.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Notifications/Channels/EmailChannel.php b/app/Notifications/Channels/EmailChannel.php index e29b99f5f..582d9a1e4 100644 --- a/app/Notifications/Channels/EmailChannel.php +++ b/app/Notifications/Channels/EmailChannel.php @@ -12,6 +12,7 @@ class EmailChannel public function send(SendsEmail $notifiable, Notification $notification): void { $useInstanceEmailSettings = $notifiable->emailNotificationSettings->use_instance_email_settings; + $customEmails = data_get($notification, 'emails', null); if ($useInstanceEmailSettings) { $settings = instanceSettings(); } else { @@ -19,7 +20,11 @@ class EmailChannel } $isResendEnabled = $settings->resend_enabled; $isSmtpEnabled = $settings->smtp_enabled; - $recipients = $notifiable->getRecipients(); + if ($customEmails) { + $recipients = [$customEmails]; + } else { + $recipients = $notifiable->getRecipients(); + } $mailMessage = $notification->toMail($notifiable); if ($isResendEnabled) { diff --git a/resources/views/livewire/notifications/email.blade.php b/resources/views/livewire/notifications/email.blade.php index 7b0878b25..194cb3b43 100644 --- a/resources/views/livewire/notifications/email.blade.php +++ b/resources/views/livewire/notifications/email.blade.php @@ -14,7 +14,7 @@
+ id="testEmailAddress" label="Recipient" required /> Send Email