i want to send an email from localhost to gmail, but it says "SMTP connect() failed" here is my code. I've also tried to change configuration php.ini and sendmail.ini but no luck. Thank you.
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = 'asd@gmail.com';
$mail->Password = 'password';
$mail->From = 'from@example.com';
$mail->FromName = 'Mailer';
$mail->addAddress('asd@gmail.com');
$mail->WordWrap = 50;
$mail->isHTML(true);
$mail->Subject = 'Email'
$mail->Body = "This is body";
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}