Error due to SMTP connection failed.So, Check your configuration first, you can check by comment the line $mail->IsSMTP();
// $mail->IsSMTP();
See below is working demo :
<?php
require 'phpmailer.php';
require 'smtp.php';
$mail = new PHPMailer;
//$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtp.gmail.com"; // sets the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = GMAIL EMAIL ID; // SMTP account username
$mail->Password = GMAIL PASSWORD; // SMTP account password
$mail->SMTPSecure = 'ssl';
$mail->From = '[email protected]';
$mail->FromName = 'Mailer';
$mail->addAddress('MAIL ID to whom you eant to send'); // Name is optional
$mail->addCC('CC EMAIL ID');
$mail->addBCC('BCC EMAIL ID');
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->Subject = 'Here is the subject';
$mail->Body = 'MESSAGE';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…