alert = $alert; $this->config = $config; $this->encrypter = $encrypter; $this->kernel = $kernel; $this->settings = $settings; } /** * Render UI for editing mail settings. This UI should only display if * the server is configured to send mail using SMTP. * * @return \Illuminate\View\View */ public function index(): View { return view('admin.settings.mail', [ 'disabled' => $this->config->get('mail.driver') !== 'smtp', ]); } /** * Handle request to update SMTP mail settings. * * @param \Pterodactyl\Http\Requests\Admin\Settings\MailSettingsFormRequest $request * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\DisplayException */ public function update(MailSettingsFormRequest $request): RedirectResponse { if ($this->config->get('mail.driver') !== 'smtp') { throw new DisplayException('This feature is only available if SMTP is the selected email driver for the Panel.'); } $values = $request->normalize(); if (array_get($values, 'mail:password') === '!e') { $values['mail:password'] = ''; } foreach ($values as $key => $value) { if (in_array($key, SettingsServiceProvider::getEncryptedKeys()) && ! empty($value)) { $value = $this->encrypter->encrypt($value); } $this->settings->set('settings::' . $key, $value); } $this->kernel->call('queue:restart'); $this->alert->success('Mail settings have been updated successfully and the queue worker was restarted to apply these changes.')->flash(); return redirect()->route('admin.settings.mail'); } }