<?php
use PHPMailer\PHPMailer\PHPMailer;
require_once __DIR__ . '/../vendor/autoload.php';

function sendApprovalEmail($to, $name, $token) {
    $mail = new PHPMailer();
    $mail->isSMTP();
    $mail->Host = 'smtp.mailtrap.io';
    $mail->SMTPAuth = true;
    $mail->Username = 'YOUR_USERNAME';
    $mail->Password = 'YOUR_PASSWORD';
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;

    $mail->setFrom("admin@yourdomain.com", "Team Recruiter");
    $mail->addAddress($to, $name);
    $mail->Subject = "You're Approved!";
    $link = BASE_URL . "payroll/setup.php?token=$token";
    $mail->Body = "Hi $name,\n\nYou're approved to join. Please setup your payroll: $link";
    return $mail->send();
}
?>