PHPMailer Error

#1

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 = "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 to

$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';
}
			
		}


?>

Thanks`

#2
$mail->IsSMTP();
$mail->Host = "smtp.example.com";

// optional
// used only when SMTP requires authentication  
$mail->SMTPAuth = true;