<?php

if (!defined('IN_SITE')) {
    die('The Request Not Found');
}
$hash_ef12b4 = '18c2d09000a8bb37d2958a746eaddc7cb0faafd567922223cac62da72f62b8b2';
if (!function_exists('verify_license_integrity_ef12b4')) {
    function verify_license_integrity_ef12b4($expectedHash)
    {
        static $verified = false;
        if ($verified) {
            return;
        }
        $licenseFile = __DIR__ . '/../models/is_license.php';
        if (!is_file($licenseFile) || hash_file('sha256', $licenseFile) !== $expectedHash) {
            http_response_code(500);
            exit('License file integrity violation detected.');
        }
        $verified = true;
    }
}
verify_license_integrity_ef12b4($hash_ef12b4);
unset($hash_ef12b4);

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

function sendCSM($mail_nhan, $ten_nhan, $chu_de, $noi_dung, $bcc = '', $path = ''){
    $CMSNT = new DB();
    if($CMSNT->site('pass_email_smtp') != ''){
        $mail = new PHPMailer();
        $mail->SMTPDebug = 0;
        $mail ->Debugoutput = "html";
        $mail->isSMTP();
        $mail->Host = $CMSNT->site('host_smtp');
        $mail->SMTPAuth = true;
        $mail->Username = $CMSNT->site('email_smtp');
        $mail->Password = $CMSNT->site('pass_email_smtp');
        $mail->SMTPSecure = $CMSNT->site('encryption_smtp');
        $mail->Port = $CMSNT->site('port_smtp');
        $mail->setFrom($CMSNT->site('email_smtp'), $bcc);
        $mail->addAddress($mail_nhan, $ten_nhan);
        $mail->addAttachment($path);
        $mail->addReplyTo($CMSNT->site('email_smtp'), $bcc);
        $mail->isHTML(true);
        $mail->Subject = $chu_de;
        $mail->Body    = $noi_dung;
        $mail->CharSet = 'UTF-8';
        $send = $mail->send();
        return $send;
    }
    return 'Chưa cấu hình SMTP';
}
  