<?php

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

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

$mail = new PHPMailer(true);

try
{
    $mail->isSMTP();

    $mail->Host       = 'smtp.gmail.com';
    $mail->SMTPAuth   = true;

    $mail->Username   = 'yourgmail@gmail.com';
    $mail->Password   = 'your_app_password';

    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
    $mail->Port       = 587;

    $mail->setFrom(
        'yourgmail@gmail.com',
        'Survey System'
    );

    $mail->addAddress(
        'recipient@gmail.com'
    );

    $mail->isHTML(true);

    $mail->Subject = 'Test Email';

    $mail->Body =
    '<h3>Hello</h3>
     <p>PHPMailer is working!</p>';

    $mail->send();

    echo "Email Sent Successfully";
}
catch (Exception $e)
{
    echo "Mailer Error: "
         . $mail->ErrorInfo;
}
?>