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.

feat: use new table or instance settings for email

peaklabs-devadaef2d3413a
diff --git a/app/Notifications/Channels/EmailChannel.php b/app/Notifications/Channels/EmailChannel.php
index 5394f6106c..0985f43933 100644
--- a/app/Notifications/Channels/EmailChannel.php
+++ b/app/Notifications/Channels/EmailChannel.php
@@ -13,7 +13,7 @@ class EmailChannel
{
try {
$this->bootConfigs($notifiable);
- $recipients = $notifiable->getRecepients($notification);
+ $recipients = $notifiable->getRecipients($notification);
if (count($recipients) === 0) {
throw new Exception('No email recipients found');
}
@@ -46,7 +46,9 @@ class EmailChannel
private function bootConfigs($notifiable): void
{
- if (data_get($notifiable, 'use_instance_email_settings')) {
+ $emailSettings = $notifiable->emailNotificationSettings;
+
+ if ($emailSettings->use_instance_email_settings) {
$type = set_transanctional_email_settings();
if (! $type) {
throw new Exception('No email settings found.');
@@ -54,24 +56,27 @@ class EmailChannel
return;
}
- config()->set('mail.from.address', data_get($notifiable, 'smtp_from_address', '[email protected]'));
- config()->set('mail.from.name', data_get($notifiable, 'smtp_from_name', 'Test'));
- if (data_get($notifiable, 'resend_enabled')) {
+
+ config()->set('mail.from.address', $emailSettings->smtp_from_address ?? '[email protected]');
+ config()->set('mail.from.name', $emailSettings->smtp_from_name ?? 'Test');
+
+ if ($emailSettings->resend_enabled) {
config()->set('mail.default', 'resend');
- config()->set('resend.api_key', data_get($notifiable, 'resend_api_key'));
+ config()->set('resend.api_key', $emailSettings->resend_api_key);
}
- if (data_get($notifiable, 'smtp_enabled')) {
+
+ if ($emailSettings->smtp_enabled) {
config()->set('mail.default', 'smtp');
config()->set('mail.mailers.smtp', [
'transport' => 'smtp',
- 'host' => data_get($notifiable, 'smtp_host'),
- 'port' => data_get($notifiable, 'smtp_port'),
- 'encryption' => data_get($notifiable, 'smtp_encryption') === 'none' ? null : data_get($notifiable, 'smtp_encryption'),
- 'username' => data_get($notifiable, 'smtp_username'),
- 'password' => data_get($notifiable, 'smtp_password'),
- 'timeout' => data_get($notifiable, 'smtp_timeout'),
+ 'host' => $emailSettings->smtp_host,
+ 'port' => $emailSettings->smtp_port,
+ 'encryption' => $emailSettings->smtp_encryption === 'none' ? null : $emailSettings->smtp_encryption,
+ 'username' => $emailSettings->smtp_username,
+ 'password' => $emailSettings->smtp_password,
+ 'timeout' => $emailSettings->smtp_timeout,
'local_domain' => null,
- 'auto_tls' => data_get($notifiable, 'smtp_encryption') === 'none' ? '0' : '',
+ 'auto_tls' => $emailSettings->smtp_encryption === 'none' ? '0' : '',
]);
}
}