_Account = $this->getKey($this->_apiCode); //验证是否具有访问这个接口的权限 if (!isset($this->_Account['email_auth'])) { HelperService::returnJson(['code' => 400, 'msg' => 'email interface unauthorized access', 'data' => []]); } } /** * 发送邮件 */ public function sendMail() { $params = $this->_params; $rule = [ 'send_name|发送者姓名' => 'require', 'theme_name|主题' => 'require', 'content|内容' => 'require', 'reply_mail|回复致xx邮箱' => 'require', 'to_mail|发送致xx邮箱' => 'require', ]; $validate = new Validate($rule); if (!$validate->check($params)) { HelperService::returnJson(['code' => 400, 'msg' => $validate->getError(), 'data' => $params]); } $mailService = new MailService(); $sendName = $params['send_name']; $themeName = $params['theme_name']; $content = $params['content']; $replyMail = $params['reply_mail']; $toMail = $params['to_mail']; $result = $mailService->send($sendName, $themeName, $content, $replyMail, $toMail); if (!$result) { HelperService::returnJson(['code' => 400, 'msg' => HelperService::$_httpErr, 'data' => []]); } HelperService::returnJson(['code' => 200, 'msg' => 'success', 'data' => []]); } }