我有用php编写的忘记密码的代码。但它没有用。每当我执行它时,它会显示邮件已发送到特定的电子邮件。但是没有邮件发送。 这是代码
<?php
include('./connect1.php');
$username = $_GET['user'];
$password = $_GET['pass'];
$email = "";
$sql = "SELECT email FROM users WHERE username='$username'";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result)>0){
$row = mysqli_fetch_assoc($result);
$email = $row['email'];
}
else{
echo "no such user exists";
}
$to = $email;
$from = "gopal@gmail.com";
$message = "
<html>
<head>
<title>Password Reset</title>
</head>
<body>
<p>Please click on this link to reset your passowrd</p>
<a href='www.someone.com/login/reset.php?user=".$username."'>Reset Password</a>
</body>
</html>
";
$subject = "Password Reset";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <gopal@gmail.com>' . "\r\n";
mail($to,$subject,$message,$headers);
echo '<script>alert("Password reset mail has been sent to'.$email.'");</script>';
?>
请帮帮我。