authorize(self::ABILITY); $profileState = Setting::getSetting('profile_complete'); $this->mailConfigurationService->saveGlobalConfig( $request->validated() ); if ($profileState !== 'COMPLETED') { Setting::setSetting('profile_complete', self::WIZARD_STEP); } return response()->json(['success' => 'mail_variables_save_successfully']); } /** * Read back the stored installation-wide transport settings. */ public function getMailEnvironment(): JsonResponse { $this->authorize(self::ABILITY); return response()->json( $this->mailConfigurationService->getGlobalConfig() ); } /** * List the transports this installation is actually able to send through. */ public function getMailDrivers(): JsonResponse { $this->authorize(self::ABILITY); return response()->json( $this->mailConfigurationService->getAvailableDrivers() ); } /** * Deliver a one-off message through the active transport so an admin can * confirm the credentials they just saved really work. */ public function testEmailConfig(Request $request): JsonResponse { $this->authorize(self::ABILITY); $this->validate($request, [ 'to' => 'required|email', 'subject' => 'required', 'message' => 'required', ]); $probe = new TestMail($request->subject, $request->message); Mail::to($request->to)->send($probe); return response()->json(['success' => true]); } }