refactor(email): allow custom email recipients in email sending logic

This commit is contained in:
Andras Bacsai
2025-03-28 19:09:36 +01:00
parent 6d9887afba
commit ebb81aff68
2 changed files with 7 additions and 2 deletions

View File

@@ -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) {

View File

@@ -14,7 +14,7 @@
<x-modal-input buttonTitle="Send Test Email" title="Send Test Email">
<form wire:submit.prevent="sendTestEmail" class="flex flex-col w-full gap-2">
<x-forms.input wire:model="testEmailAddress" placeholder="test@example.com"
id="testEmailAddress" label="Recipients" required />
id="testEmailAddress" label="Recipient" required />
<x-forms.button type="submit" @click="modalOpen=false">
Send Email
</x-forms.button>