Add no encryption option for SMTP settings
Related to #4311 Add option to configure SMTP settings without encryption. * Update `app/Livewire/Notifications/Email.php` and `app/Livewire/SettingsEmail.php` to include "No Encryption" option in the `smtpEncryption` field and update validation rules. * Modify `app/Notifications/Channels/EmailChannel.php` to handle the "No Encryption" option in the `bootConfigs` method. * Add `set_transanctional_email_settings` function in `app/Livewire/Help.php` to support the "No Encryption" option. * Update `config/mail.php` to handle the "No Encryption" option in the mail configuration.
This commit is contained in:
@@ -56,3 +56,35 @@ class Help extends Component
|
|||||||
return view('livewire.help')->layout('layouts.app');
|
return view('livewire.help')->layout('layouts.app');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_transanctional_email_settings($settings = null)
|
||||||
|
{
|
||||||
|
if (is_null($settings)) {
|
||||||
|
$settings = instanceSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($settings->resend_enabled) {
|
||||||
|
config()->set('mail.default', 'resend');
|
||||||
|
config()->set('resend.api_key', $settings->resend_api_key);
|
||||||
|
|
||||||
|
return 'resend';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($settings->smtp_enabled) {
|
||||||
|
config()->set('mail.default', 'smtp');
|
||||||
|
config()->set('mail.mailers.smtp', [
|
||||||
|
'transport' => 'smtp',
|
||||||
|
'host' => $settings->smtp_host,
|
||||||
|
'port' => $settings->smtp_port,
|
||||||
|
'encryption' => $settings->smtp_encryption === 'none' ? null : $settings->smtp_encryption,
|
||||||
|
'username' => $settings->smtp_username,
|
||||||
|
'password' => $settings->smtp_password,
|
||||||
|
'timeout' => $settings->smtp_timeout,
|
||||||
|
'local_domain' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return 'smtp';
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Email extends Component
|
|||||||
#[Validate(['nullable', 'numeric'])]
|
#[Validate(['nullable', 'numeric'])]
|
||||||
public ?int $smtpPort = null;
|
public ?int $smtpPort = null;
|
||||||
|
|
||||||
#[Validate(['nullable', 'string'])]
|
#[Validate(['nullable', 'string', 'in:tls,ssl,none'])]
|
||||||
public ?string $smtpEncryption = null;
|
public ?string $smtpEncryption = null;
|
||||||
|
|
||||||
#[Validate(['nullable', 'string'])]
|
#[Validate(['nullable', 'string'])]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class SettingsEmail extends Component
|
|||||||
#[Validate(['nullable', 'numeric', 'min:1', 'max:65535'])]
|
#[Validate(['nullable', 'numeric', 'min:1', 'max:65535'])]
|
||||||
public ?int $smtpPort = null;
|
public ?int $smtpPort = null;
|
||||||
|
|
||||||
#[Validate(['nullable', 'string'])]
|
#[Validate(['nullable', 'string', 'in:tls,ssl,none'])]
|
||||||
public ?string $smtpEncryption = null;
|
public ?string $smtpEncryption = null;
|
||||||
|
|
||||||
#[Validate(['nullable', 'string'])]
|
#[Validate(['nullable', 'string'])]
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class EmailChannel
|
|||||||
'transport' => 'smtp',
|
'transport' => 'smtp',
|
||||||
'host' => data_get($notifiable, 'smtp_host'),
|
'host' => data_get($notifiable, 'smtp_host'),
|
||||||
'port' => data_get($notifiable, 'smtp_port'),
|
'port' => data_get($notifiable, 'smtp_port'),
|
||||||
'encryption' => data_get($notifiable, 'smtp_encryption'),
|
'encryption' => data_get($notifiable, 'smtp_encryption') === 'none' ? null : data_get($notifiable, 'smtp_encryption'),
|
||||||
'username' => data_get($notifiable, 'smtp_username'),
|
'username' => data_get($notifiable, 'smtp_username'),
|
||||||
'password' => data_get($notifiable, 'smtp_password'),
|
'password' => data_get($notifiable, 'smtp_password'),
|
||||||
'timeout' => data_get($notifiable, 'smtp_timeout'),
|
'timeout' => data_get($notifiable, 'smtp_timeout'),
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ return [
|
|||||||
'transport' => 'smtp',
|
'transport' => 'smtp',
|
||||||
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
||||||
'port' => env('MAIL_PORT', 587),
|
'port' => env('MAIL_PORT', 587),
|
||||||
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
'encryption' => env('MAIL_ENCRYPTION', 'tls') === 'none' ? null : env('MAIL_ENCRYPTION', 'tls'),
|
||||||
'username' => env('MAIL_USERNAME'),
|
'username' => env('MAIL_USERNAME'),
|
||||||
'password' => env('MAIL_PASSWORD'),
|
'password' => env('MAIL_PASSWORD'),
|
||||||
'timeout' => null,
|
'timeout' => null,
|
||||||
|
|||||||
Reference in New Issue
Block a user