I want to create Contact form for my php project and I decided to use phpmailer so here is my code:
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'smtp.gmail.com';
$mail->Username = 'test@gmail.com';
$mail->Password = 'password';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->isHTML();
$mail->Subject = 'Contact From My Friends';
$mail->Body = <p>Message Body</p>;
$mail->FromName = 'Contact';
$mail->AddAddress('test@gmail.com','name');
if ($mail->send()) {
echo "success"
} else {
echo "Failed";
}
The problem I have is that when I try to send a message I receive:
Message could not be sent.Mailer Error: SMTP connect() failed. Troubleshooting PHPMailer Problems
Also I disabled openssl on Xampp php.ini:
extension=php_openssl.dll
I tried a lot of things but I don't know what is causing the problem. Please help me.