I have an issue in sending mail from PHPMailer. When I try to send a message, I get an error message which is
Message could not be sent. Mailer Error:Could not instantiate mail function.
My SMTP is correct, I can't find the problem. Can anyone help me find the problem? Thanks
<?php
require "autoload.php";
if(isset($_POST["submit"])){
$mail = new PHPMailer(true);
$sender = "demo@gmail.com";
//SMTP
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = demo@gmail.com; // SMTP username
$mail->Password = '1234567'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS
$mail->Port = 587; // TCP port to connect
$mail->From = "demo@gmail.com";
$mail->FromName = 'Mailer';
$mail->setFrom(demo@gmail.com, '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';
}
}
?>