<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once '../includes/mailer.php';

echo "<h2>SMTP Mail Diagnostic Test</h2>";

$mailer = new Mailer();
$testRecipient = "rawcoaster@gmail.com"; // Replace with your target email
$sent = $mailer->send($testRecipient, "Test User", "Test Email Subject", "<p>Testing SMTP connection...</p>");

if ($sent) {
    echo "<p style='color: green; font-weight: bold;'>SUCCESS: Email sent successfully!</p>";
} else {
    echo "<p style='color: red; font-weight: bold;'>FAILED: Could not send email.</p>";
    echo "<pre style='background: #1e1e1e; color: #ff6b6b; padding: 15px; border-radius: 8px;'>Error Details:\n" . htmlspecialchars($mailer->lastError ?: ($_SESSION['mail_error'] ?? 'Unknown Error')) . "</pre>";
}