protected function sendResetMail($userData)
    {
        if (!$this->mailer) {
            $this->getLogger()->critical("Sending mail but no mailer is set!");
            return;
        }
        
        $url = $this->createResetToken($userData['name']);
               
        // Replaces Pico-specific placeholders (like %site_title%)
        $message = $this->picoAuth->getPico()->substituteFileContent($this->config["emailMessage"]);
        $subject = $this->picoAuth->getPico()->substituteFileContent($this->config["emailSubject"]);
        
        // Replaces placeholders in the configured email message template
        $message = str_replace("%url%", $url, $message);
        $message = str_replace("%username%", $userData['name'], $message);
        
        $this->mailer->setup();
        $this->mailer->setTo($userData['email']);
        $this->mailer->setSubject($subject);
        $this->mailer->setBody($message);
        
        if (!$this->mailer->send()) {
            $this->getLogger()->critical("Mailer error: {e}", ["e" => $this->mailer->getError()]);
        } else {
            $this->getLogger()->info("PwReset email sent to {email}", ["email" => $userData['email']]);
        }
    }