Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

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

Andras Bacsaiebb81aff68c7
diff --git a/app/Notifications/Channels/EmailChannel.php b/app/Notifications/Channels/EmailChannel.php
index e29b99f5f5..582d9a1e46 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 7b0878b25d..194cb3b439 100644
--- a/resources/views/livewire/notifications/email.blade.php
+++ b/resources/views/livewire/notifications/email.blade.php
@@ -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="[email protected]"
- id="testEmailAddress" label="Recipients" required />
+ id="testEmailAddress" label="Recipient" required />
<x-forms.button type="submit" @click="modalOpen=false">
Send Email
</x-forms.button>