<?php

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

    require 'vendor/autoload.php';

    function SendMail($address, $subject, $body) {
        try {
            $mail = new PHPMailer(true);
            // Server settings
            $mail->isSMTP();
            $mail->Host = 'smtp.gmail.com'; //SMTP server
            $mail->SMTPAuth = true;
            $mail->Username = ''; //email address
            $mail->Password = ''; // app password
            $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
            $mail->Port = 587;
        
            $mail->setFrom('', 'Innova');
            $mail->addAddress("{$address}");
        
            $mail->Subject = $subject;
            $mail->Body    = $body;
        
            $mail->send();
            echo 'Message has been sent';
        } catch (Exception $e) {
            echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
        }
    }
?>