SMTPDebug = SMTP::DEBUG_SERVER; $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'karnando1994@gmail.com'; $mail->Password = 'rktz hnyc ykyr gbzh'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; $mail->Port = 465; //Recipients $mail->setFrom('from@example.com', 'PETTA EXPRESS'); $mail->addAddress($email); $mail->addAddress('ellen@example.com'); $mail->addReplyTo('info@example.com', 'Information'); //Content $mail->isHTML(true); $mail->Subject = 'Reset Password'; $mail->Body = 'Your Otp to reset Password is [' . $otp . ']'; $mail->AltBody = 'Reset password to access codes easy application'; if ($mail->send()) echo 'Message has been sent'; else echo 'Failed to send otp'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } } else echo 'reset password failed'; } } else { echo "db conn failed"; } } else { echo "All fields is required"; }