From eac78340838478fe97313415bfedfe9779978d6a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 2 Sep 2023 13:39:44 +0200 Subject: [PATCH] fix: form address --- app/Notifications/Channels/EmailChannel.php | 26 ++------------------- bootstrap/helpers/shared.php | 2 ++ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/app/Notifications/Channels/EmailChannel.php b/app/Notifications/Channels/EmailChannel.php index 0c042fcfc..e0f9edac0 100644 --- a/app/Notifications/Channels/EmailChannel.php +++ b/app/Notifications/Channels/EmailChannel.php @@ -9,7 +9,6 @@ class EmailChannel { - private bool $isResend = false; public function send(SendsEmail $notifiable, Notification $notification): void { $this->bootConfigs($notifiable); @@ -20,33 +19,14 @@ public function send(SendsEmail $notifiable, Notification $notification): void } $mailMessage = $notification->toMail($notifiable); - // if ($this->isResend) { Mail::send( [], [], fn (Message $message) => $message - ->from( - data_get($notifiable, 'smtp_from_address'), - data_get($notifiable, 'smtp_from_name'), - ) ->to($recepients) ->subject($mailMessage->subject) ->html((string)$mailMessage->render()) ); - // } else { - // Mail::send( - // [], - // [], - // fn (Message $message) => $message - // ->from( - // data_get($notifiable, 'smtp_from_address'), - // data_get($notifiable, 'smtp_from_name'), - // ) - // ->bcc($recepients) - // ->subject($mailMessage->subject) - // ->html((string)$mailMessage->render()) - // ); - // } } private function bootConfigs($notifiable): void @@ -56,13 +36,11 @@ private function bootConfigs($notifiable): void if (!$type) { throw new Exception('No email settings found.'); } - if ($type === 'resend') { - $this->isResend = true; - } return; } + config()->set('mail.from.address', data_get($notifiable, 'smtp_from_address')); + config()->set('mail.from.name', data_get($notifiable, 'smtp_from_name')); if (data_get($notifiable, 'resend_enabled')) { - $this->isResend = true; config()->set('mail.default', 'resend'); config()->set('resend.api_key', data_get($notifiable, 'resend_api_key')); } diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 249f76920..7056b159b 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -149,6 +149,8 @@ function set_transanctional_email_settings(InstanceSettings | null $settings = n if (!$settings) { $settings = InstanceSettings::get(); } + config()->set('mail.from.address', data_get($settings, 'smtp_from_address')); + config()->set('mail.from.name', data_get($settings, 'smtp_from_name')); if (data_get($settings, 'resend_enabled')) { config()->set('mail.default', 'resend'); config()->set('resend.api_key', data_get($settings, 'resend_api_key'));