This my code,
require_once("PHPMailer/class.PHPMailer.php");
$mail = new PHPMailer();
/* receiver details and message - start */
$toid = "example@gmail.com";
$toname = "Example";
$msg = "First name : ".$_POST["fname"] . "<br>";
$msg .= "Last name : ".$_POST["lname"]. "<br>";;
$msg .= "Email : ".$_POST["email"]. "<br>";;
$msg .= "Mobile : ".$_POST["mobile"]. "<br>";;
$msg .= "Message : ".$_POST["msg"];
$subject = "sample subject";
/* receiver details and message - end */
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPKeepAlive = true;
/* mail smtp configuration - start */
$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->Username = 'test@gmail.com';
$mail->Password = 'xxxxxx';
/* mail smtp configuration - end */
$mail->From = "test@gmail.com";
$mail->FromName = "from name";
$mail->AddAddress($toid, $toname);
$mail->Subject = $subject;
$mail->Body = $msg;
$mail->IsHTML(true);
if($mail->Send()){
echo "success";
}else{
echo "Failure";
}
When run the above , it throws
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in C:\xampp\htdocs\mail\PHPMailer\class.smtp.php on line 200