I am having an issue with phpmailer. When I send a message, I get an error which states, “Could not instantiate mail function.” I set up the smtp correctly but can’t find an issue. Here is my code:
`<?php
require "autoload.php";
if(isset($_POST["submit"])){
$mail = new PHPMailer(true);
$sender = "[email protected]";
SMTP
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = [email protected]; // SMTP username
$mail->Password = '1234567'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS
$mail->Port = 587; // TCP port to connect to
$mail->From = "[email protected]";
$mail->FromName = 'Mailer';
$mail->setFrom([email protected], 'Mailer');
$mail->addAddress($_POST["receiver"]); // Name is optional
$mail->Subject = $_POST["subject"];
$mail->Body = $_POST["message"];
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
?>
Thanks`