<?php
require_once 'includes/config.php';
require_once 'includes/functions.php';

// IMPORTANT: Temporarily enable debug output
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
$mail->SMTPDebug = 2;  // This will show detailed connection logs

try {
    $mail->isSMTP();
    $mail->Host       = SMTP_HOST;
    $mail->SMTPAuth   = true;
    $mail->Username   = SMTP_USER;
    $mail->Password   = SMTP_PASS;
    $mail->SMTPSecure = SMTP_SECURE;
    $mail->Port       = SMTP_PORT;
    
    // Add timeout settings for cPanel
    $mail->Timeout = 30;
    
    $mail->setFrom(SMTP_USER, SITE_NAME);
    $mail->addAddress('your-personal-email@gmail.com'); // Change to your email
    
    $mail->isHTML(true);
    $mail->Subject = 'Test Email from cPanel';
    $mail->Body    = '<h2>Success!</h2><p>Your cPanel SMTP is working correctly.</p>';
    
    if ($mail->send()) {
        echo "✅ Email sent successfully!";
    }
} catch (Exception $e) {
    echo "❌ Failed: " . $mail->ErrorInfo;
}
?>