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

require __DIR__ . '/vendor/autoload.php';

$mail = new PHPMailer(true);

try {
    $mail->isSMTP();
    $mail->Host = 'mail.iwankciwat.my.id';
    $mail->SMTPAuth = true;
    $mail->Username = 'noreply@iwankciwat.my.id';
    $mail->Password = 'Kciwat0825'; // ganti jika sudah ubah
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // SSL
    $mail->Port = 465;

    $mail->setFrom('noreply@iwankciwat.my.id', 'Tes SMTP');
    $mail->addAddress('kciwatiwan015@gmail.com'); // email tujuan untuk cek

    $mail->isHTML(true);
    $mail->Subject = 'Tes Email dari Hosting';
    $mail->Body = 'Ini adalah pengujian SMTP dari Rumahweb melalui PHPMailer.';

    $mail->SMTPDebug = 2; // debug output
    $mail->send();

    echo '✅ Email berhasil dikirim.';
} catch (Exception $e) {
    echo "❌ Gagal: {$mail->ErrorInfo}";
}
