<?php

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

require 'vendor/autoload.php';

function sendTicketEmail($to, $subject, $body) {
    $mail = new PHPMailer(true);

    try {
	$mail->Host = 'web05.ouiheberg.com'; 
   	$mail->SMTPAuth = true;
   	$mail->Username = 'no-reply@imators.systems';
   	$mail->Password = 'imators.managements4455*#@';
   	$mail->SMTPSecure = 'PHPMailer::ENCRYPTION_STARTTLS';
   	$mail->Port = 465;


        // Recipients
        $mail->setFrom('support@imators.com', 'Imators Support');
        $mail->addAddress($to);

        // Content
        $mail->isHTML(true);
        $mail->Subject = $subject;
        $mail->Body = $body;

        $mail->send();
        return true;
    } catch (Exception $e) {
        error_log("Mail Error: {$mail->ErrorInfo}");
        return false;
    }
}