register($email); case "forgetPassword": return $this->forgetPassword($email); default: throw new ClientException("source未匹配"); } } public function register($email): bool { $captcha = Cache::remember("registerCaptcha" . $email, 10, function () { return rand(100000, 999999); }); // try { Mail::to($email)->send(new RegisterEmail($captcha)); // } catch (\Exception $e) { // logger()->error("邮件发送失败 ". $e->getMessage()); // throw new ClientException("邮件发送失败,请稍后再试"); // } return true; } public function forgetPassword($email): bool { } private function send($email, $source) { } }