I am developing an android application, I am doing below things for forgot password.
<?php
use PHPMailer\PHPMailer\PHPMailer;
//sender address
$name = "name";
$email = "emailaddress@gmail.com";
require_once "PHPMailer/PHPMailer.php";
require_once "PHPMailer/SMTP.php";
require_once "PHPMailer/Exception.php";
$mail = new PHPMailer(true);
function sendMail($password){
global $mail,$email,$name;
$response = array();
try{
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username="myemail@gmail.com";
$mail->Password="myemailpassword";
$mail->Port=465;
$mail->SMTPSecure="ssl";
$mail->isHtML(true);
$mail->setFrom($email,$name);
$mail->addAddress("friendemail@gmail.com","friendname");
$mail->Subject = ("FORGOT PASSWORD");
$mail->Body="THIS IS BODY";
$res = $mail->send();
$response['error'] = false;
$response['message'] = "Password sent to your Email id ....";
}
catch(Exception $e){
$response['error'] = true;
$response['message'] = $mail->ErrorInfo;
}
return $response;
}
?>
I hosted my database and files in 00webhost
free web hosting platform link
And I am using postman
tool to check the response
If I run same file in localhost, it will send the email
Even I tried with enabling the Less secure app access in gmail account.
But I still not able to send mail using OOOwebhost.
Thanks in advance..