<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/phpmailer/src/Exception.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/phpmailer/src/PHPMailer.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/phpmailer/src/SMTP.php';

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

echo "<h2>Testing Email - pastijepe.online</h2>";

$mail = new PHPMailer(true);

try {
    // Aktifkan debug
    $mail->SMTPDebug = SMTP::DEBUG_SERVER;
    
    $mail->isSMTP();
    
    // ============ GUNAKAN HOSTNAME SERVER ANDA ============
    $mail->Host       = 'premium282.web-hosting.com'; // ← INI YANG BENAR!
    $mail->SMTPAuth   = true;
    $mail->Username   = 'cs@pastijepe.online';
    $mail->Password   = 'Moneycome$$'; // Ganti dengan password email Anda
    // =======================================================
    
    // Coba port 465 dengan SSL
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // 'ssl'
    $mail->Port       = 465;
    
    // Force autentikasi metode LOGIN
    $mail->AuthType = 'LOGIN';
    
    // From HARUS SAMA dengan Username
    $mail->setFrom('cs@pastijepe.online', 'Jago Hongkong');
    $mail->addAddress('jononew78@mail.com'); // Ganti dengan email Anda sendiri
    
    $mail->isHTML(false);
    $mail->Subject = 'Test Email - Jagohongkong';
    $mail->Body    = 'Ini adalah test email. Jika Anda menerima ini, berarti SMTP berfungsi!';
    
    $mail->send();
    echo "<p style='color: green; font-size: 18px;'>✅ Email berhasil dikirim!</p>";
    
} catch (Exception $e) {
    echo "<p style='color: red; font-size: 18px;'>❌ Gagal: " . $mail->ErrorInfo . "</p>";
}
?>