feat: use new table or instance settings for email
This commit is contained in:
@@ -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', 'test@example.com'));
|
||||
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 ?? 'test@example.com');
|
||||
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' : '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user