diff --git a/airtime_mvc/application/controllers/LoginController.php b/airtime_mvc/application/controllers/LoginController.php index bb39d2978..5aab66d38 100644 --- a/airtime_mvc/application/controllers/LoginController.php +++ b/airtime_mvc/application/controllers/LoginController.php @@ -118,8 +118,12 @@ class LoginController extends Zend_Controller_Action if (!empty($user)) { $auth = new Application_Model_Auth(); - $auth->sendPasswordRestoreLink($user, $this->view); - $this->_helper->redirector('password-restore-after', 'login'); + $success = $auth->sendPasswordRestoreLink($user, $this->view); + if ($success) { + $this->_helper->redirector('password-restore-after', 'login'); + } else { + $form->email->addError($this->view->translate("Email could not be sent. Check your mail server settings and ensure it has been configured properly.")); + } } else { $form->email->addError($this->view->translate("Given email not found.")); diff --git a/airtime_mvc/application/models/Auth.php b/airtime_mvc/application/models/Auth.php index fa2ab8bd3..cc3cfe4cf 100644 --- a/airtime_mvc/application/models/Auth.php +++ b/airtime_mvc/application/models/Auth.php @@ -31,7 +31,9 @@ class Application_Model_Auth { $message = "Click this link: {$e_link_protocol}://{$e_link_base}{$e_link_path}"; - Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail()); + $success = Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail()); + + return $success; } public function invalidateTokens($user, $action) @@ -97,4 +99,4 @@ class Application_Model_Auth { return $string; } -} \ No newline at end of file +} diff --git a/airtime_mvc/application/models/Email.php b/airtime_mvc/application/models/Email.php index 7a111a572..eda6a63d4 100644 --- a/airtime_mvc/application/models/Email.php +++ b/airtime_mvc/application/models/Email.php @@ -12,6 +12,7 @@ class Application_Model_Email { */ public static function send($subject, $message, $tos, $from = null) { + $success = true; $mail = new Zend_Mail('utf-8'); $mail->setSubject($subject); $mail->setBodyText($message); @@ -21,6 +22,12 @@ class Application_Model_Email { $mail->addTo($to); } - $mail->send(); + try { + $mail->send(); + } catch (Exception $e) { + $success = false; + } + + return $success; } -} \ No newline at end of file +}