/** * Do actual e-mail test by sending the e-mail to the given e-mail address * @return \Bootstrap\Response\Form */ public function testEmailAjax() { $validator = Validator::create(array('to' => 'required|email')); if ($validator->failed()) { return BootstrapUI::formResponse()->failedOn($validator); } if (!Mail::isEnabled()) { return BootstrapUI::formResponse()->message('Mail sender is not enabled!'); } $params = $validator->getParamsObj(); $mail = Mail::create()->from('no-replay@' . Request::hostNameDomain(), Request::hostName())->to($params->to)->subject('Configuration test mail')->body("If you got this e-mail, then your mail configuration is just fine!\n\n" . Url::current()); try { if ($mail->send()) { Log::info("Test e-mail is sent to {$params->to}"); return BootstrapUI::formResponse()->message('Test e-mail is sent!'); } } catch (Exception $e) { Log::info("Couldn\\'t send test e-mail to {$params->to}"); Log::exception($e); // we'll log this if needed, just to make sure it won't be forgotten return BootstrapUI::formResponse()->failed('E-mail wasn\'t sent:<br/>' . $e->getMessage()); // show user the actual error } }