<?php

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

class Mail
{

    public function __construct()
    {
    }

    public function send_mail($user_mail, $user_name, $mail_subject, $mail_body, $mail_attachment, $html_mail): bool
    {
        $mail = new PHPMailer(true);

        $mail->isSMTP();

        //$mail->Host = 'mail.cltinspection.app';
        $mail->Host = 'mail.cltinspection.com';
        $mail->Port = 465;
        $mail->SMTPAuth = true;
        $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
        // $mail->Username = 'noreply@cltinspection.app';
        $mail->Username = 'noreply@cltinspection.com';

        $mail->Password = 'bbinKQG6c*D9';


        try {
            $mail->setFrom(site_mail, site_name);
            $mail->addAddress($user_mail, $user_name);
            $mail->isHTML(true);
            $mail->Subject = $mail_subject;



      

            if ($mail_attachment != null) {
                $mail->addAttachment(report_via_loc . $mail_attachment);
            }

            $mail->Body = $mail_body;
            $send_sta = $mail->send();
        } catch (Exception $e) {
            $send_sta = false;
        }
        return $send_sta;
    }

}
