[ [ 'code' => 'DisplayException', 'status' => '400', 'detail' => 'This feature is only available if SMTP is the selected email driver for the Panel.', ], ], ]; /** * Update mail settings. */ #[Endpoint('Update mail settings', 'Updates SMTP mail settings and restarts queued workers so they reload configuration.')] #[ScribeResponse(status: 204, description: 'Mail settings updated.')] #[ScribeResponse(self::SMTP_DRIVER_ERROR, status: 400, description: 'The panel is not configured to use SMTP mail.')] public function __invoke(UpdateMailSettingsRequest $request, Kernel $kernel, Encrypter $encrypter, ConfigRepository $config): Response { throw_if($config->get('mail.default') !== 'smtp', DisplayException::class, 'This feature is only available if SMTP is the selected email driver for the Panel.'); $values = $request->normalize(); if (Arr::get($values, 'mail:mailers:smtp:password') === '!e') { $values['mail:mailers:smtp:password'] = ''; } foreach ($values as $key => $value) { if (in_array($key, SettingsServiceProvider::getEncryptedKeys()) && ! empty($value)) { $value = $encrypter->encrypt($value); } // SAFETY: settings are persisted in the environment store as strings; null retains its deletion semantics. Setting::put('settings::'.$key, ($value) === null ? null : (string) $value); } $kernel->call('queue:restart'); return $this->returnNoContent(); } }