to = $to; $this->code = $code; $this->title = $title ?? '邮箱验证码'; Config::set('mail.mailers.smtp.host', SystemConfig::get('mail_host')); Config::set('mail.mailers.smtp.port', SystemConfig::get('mail_port')); Config::set('mail.mailers.smtp.username', SystemConfig::get('mail_username')); Config::set('mail.mailers.smtp.password', SystemConfig::get('mail_password')); Config::set('mail.from.address', SystemConfig::get('mail_from_address')); Config::set('mail.from.name', SystemConfig::get('mail_from_name')); } public function middleware() { return [new RateLimited]; } /** * Execute the job. */ public function handle(): void { Mail::to($this->to) ->send(new SendEmail($this->code, $this->title)); } public function failed(Throwable $exception) { Mail::to($this->to) ->send(new SendEmail($this->code, $this->title)); } }