<?php
require_once 'PHPMailer/PHPMailer.php';
require_once 'PHPMailer/SMTP.php';
require_once 'PHPMailer/Exception.php';

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

function kirimEmailVerifikasi($email, $nama_wali, $kode) {
    $mail = new PHPMailer();  // ← INI WAJIB ADA

    $mail->isSMTP();
    $mail->Host = 'mail.jasabuatwebmrrobot.com';
    $mail->SMTPAuth = true;
    $mail->Username = 'info@jasabuatwebmrrobot.com';
    $mail->Password = '@deLia2017';
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
    $mail->Port = 465;

    $mail->setFrom('info@jasabuatwebmrrobot.com', 'Admin Pendaftaran');
    $mail->addAddress($email, $nama_wali);

    $mail->Subject = 'Kode Verifikasi Pendaftaran';
    $mail->Body    = "Halo $nama,\n\nKode verifikasi Anda: $kode\n\nTerima kasih.";

    if(!$mail->send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
        header("Location: verifikasi?email=$email");
        exit;
    }
}
?>
