Merge branch '2.1.x' into devel

Conflicts:
	airtime_mvc/application/models/Email.php
This commit is contained in:
denise 2012-06-14 15:30:33 -04:00
commit 70bfe031ef
3 changed files with 27 additions and 8 deletions

View file

@ -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."));

View file

@ -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;
}
}
}

View file

@ -13,6 +13,8 @@ class Application_Model_Email {
public static function send($subject, $message, $tos, $from = null)
{
$mailServerConfigured = Application_Model_Preference::GetMailServerConfigured() == true ? true : false;
$success = true;
if ($mailServerConfigured) {
$username = Application_Model_Preference::GetMailServerEmailAddress();
$password = Application_Model_Preference::GetMailServerPassword();
@ -35,7 +37,7 @@ class Application_Model_Email {
$transport = new Zend_Mail_Transport_Smtp($mailServer, $config);
}
$mail = new Zend_Mail('utf-8');
$mail->setSubject($subject);
$mail->setBodyText($message);
@ -46,10 +48,21 @@ class Application_Model_Email {
if ($mailServerConfigured) {
$mail->setFrom(isset($from) ? $from : Application_Model_Preference::GetMailServerEmailAddress());
$mail->send($transport);
try {
$mail->send($transport);
} catch (Exception $e) {
$success = false;
}
} else {
$mail->setFrom(isset($from) ? $from : Application_Model_Preference::GetSystemEmail());
$mail->send();
}
try {
$mail->send();
} catch (Exception $e) {
$success = false;
}
}
return $success;
}
}