'danger', 'message' => 'Invalid input. Please fill out all fields correctly.']; header("Location: index.php#contact"); exit; } // The email will be sent to the address configured in .env (MAIL_TO) // The user's email is used as the Reply-To address. $subject = 'New Account Request from ' . $name; $res = MailService::sendContactMessage($name, $email, $message, null, $subject); if (!empty($res['success'])) { $_SESSION['status'] = ['type' => 'success', 'message' => 'Thank you for your request! We will get back to you shortly.']; } else { // Avoid showing detailed errors to the user. // error_log('MailService Error: ' . ($res['error'] ?? 'Unknown error')); $_SESSION['status'] = ['type' => 'danger', 'message' => 'Sorry, there was an error sending your message. Please try again later.']; } } else { $_SESSION['status'] = ['type' => 'danger', 'message' => 'Invalid request method.']; } header("Location: index.php#contact"); exit;