Here my php code for contact form using PhpMailer.
<?php
use PHPMailer\PHPMailer\PHPMailer;
include_once "PHPMailer/PHPMailer.php";
include_once "PHPMailer/Exception.php";
include_once "PHPMailer/SMTP.php";
if (isset($_POST['submit'])) {
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];
echo $subject . "<br/>";
echo $email . "<br/>";
echo $message . "<br/>";
$mail = new PHPMailer();
$mail->addAddress('example@gmail.com');
$mail->setFrom($email);
$mail->Subject = $subject;
$mail->isHTML(true);
$mail->Body = $message;
if ($mail->send())
echo "Your email has been sent, thank you!";
else
echo "Please try again!";
}
?>
It shows "Your email has been sent, thank you", but does not send anyting. How can solve it?