<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

// Include PHPMailer classes
require __DIR__ . '/includes/PHPMailer/PHPMailer.php';
require __DIR__ . '/includes/PHPMailer/SMTP.php';
require __DIR__ . '/includes/PHPMailer/Exception.php';

$mail = new PHPMailer(true);

try {
    // Server settings
    $mail->isSMTP();
    $mail->Host       = 'mail.tandddrivingacademy.com';
    $mail->SMTPAuth   = true;
    $mail->Username   = 'info@tandddrivingacademy.com';
    $mail->Password   = '!DriveRightTX!'; // <-- replace with real password
    $mail->SMTPSecure = 'ssl';
    $mail->Port       = 465;

    // Recipients
    $mail->setFrom('info@tandddrivingacademy.com', 'T&D Driving Academy');
    $mail->addAddress('your.email@example.com', 'Your Name'); // Change this to YOUR email for test

    // Content
    $mail->isHTML(true);
    $mail->Subject = 'Test Email from T&D System';
    $mail->Body    = '✅ <strong>This is a test email</strong> from the student scheduling system. Looks like everything is working!';

    $mail->send();
    echo '✅ Email has been sent successfully.';
} catch (Exception $e) {
    echo "❌ Email could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
