public function actionSendEmail() { $emailBindRequestForm = new EmailBindRequestForm(); Yii::$app->response->format = Response::FORMAT_JSON; $emailBindRequestForm->email = Yii::$app->session['emailBind']; if ($emailBindRequestForm->validate() && $emailBindRequestForm->sendEmail()) { return ['status' => 'ok']; } return ['status' => 'err', 'msg' => $emailBindRequestForm->getFirstError('email')]; }
/** * 发送email * * @return array */ public function actionSendEmail() { $model = new EmailBindRequestForm(); $model->email = Yii::$app->session['emailBind']; if ($model->sendEmail()) { return ['status' => 'success', 'data' => []]; } else { return ['status' => 'fail', 'data' => ['errors' => $model->getErrors('email') ?: ['验证码发送失败,请稍后再试!']]]; } }