<?php
// testar_funcionamento.php
require_once 'config_smtp.php';
require __DIR__ . '/PHPMailer/PHPMailer-master/src/Exception.php';
require __DIR__ . '/PHPMailer/PHPMailer-master/src/PHPMailer.php';
require __DIR__ . '/PHPMailer/PHPMailer-master/src/SMTP.php';

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

echo "<h2>✅ Teste com Host CORRETO: mail.tvitecnologia.com.br</h2>";

$mail = new PHPMailer(true);

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;
    $mail->CharSet    = 'UTF-8';
    
    $mail->SMTPOptions = [
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        ]
    ];
    
    $mail->setFrom(SMTP_USER, 'Teste Final');
    $mail->addAddress('SEU-EMAIL@gmail.com'); // COLOQUE SEU GMAIL
    
    $mail->isHTML(true);
    $mail->Subject = '🚀 Teste Final - Configuração OK!';
    $mail->Body = '<h2>Parabéns!</h2><p>A configuração SMTP está funcionando perfeitamente.</p>';
    
    $mail->send();
    echo "<p style='color: green; font-weight: bold;'>✅ EMAIL ENVIADO COM SUCESSO PARA GMAIL!</p>";
    
} catch (Exception $e) {
    echo "<p style='color: red; font-weight: bold;'>❌ Erro: " . $mail->ErrorInfo . "</p>";
}
?>