Exemplo n.º 1
0
 /**
  * @throws ErrorException
  */
 private function _sendVcode()
 {
     $vcodeTime = Config::getInstance()->getProperty('setTime.vcode');
     $content = '您的验证码为:' . $this->code . '请在' . $vcodeTime / 60 . '分钟内进行处理';
     if (($old = self::findByField($this->field)) !== null && $old->created_at > time() - $vcodeTime) {
         throw new ErrorException($vcodeTime - (time() - $old->created_at), ErrorCode::Vcode_short_time);
     }
     if ($this->type == self::TYPE_EMAIL) {
         try {
             Utils::sendEmail($this->field, '玖信贷邮箱验证码', $content);
         } catch (\Exception $e) {
             throw new ErrorException('验证码发送错误', ErrorCode::Send_email_error);
         }
     } else {
         if (Utils::sendSMS($this->field, $content) < 0) {
             throw new ErrorException('验证码发送错误', ErrorCode::Send_phone_error);
         }
     }
 }