/** * 忘记密码 * Enter description here ... */ public function actionForgetPassword() { $model = new UserInfo(); if (isset($_POST['UserInfo'])) { $model->attributes = $_POST['UserInfo']; $user = User::model()->findByAttributes(array('email' => $model->email)); if (!$user) { } else { $user->resetPassword = DxdUtil::randCode(32); if ($user->save()) { $link = $this->createAbsoluteUrl('u/resetPassword', array('resetPassword' => $user->resetPassword, 'email' => urldecode($user->email))); //Yii::import('ext.email.Email'); //$email = new Email; $subject = Yii::app()->params['settings']['site']['name'] . "-" . Yii::t('app', "密码找回"); $content = $this->renderPartial('_forget_password_email_content', array('link' => $link), true); $toAddr = $user->email; if (DxdUtil::postMail($toAddr, $subject, $content)) { $this->render('forgetPasswordSend', array('user' => $user), false); } } } } else { $this->render('forgetPassword', array('model' => $model)); } }