0
I have the following code that sends a password reset link, but the problem here is that if the email requesting a new password is gmail.com sends without any problem but if it is another email like Hotmail.com etc. simply does not send any link.
<?php
include("config.php");
if(isset($_POST['submit_email']) && isset($_POST['email'])) {
$email = mysqli_real_escape_string($conn, $_POST['email']);
$sql = "SELECT * FROM registo WHERE email = '$email'";
$r = mysqli_query($conn, $sql);
$count = mysqli_num_rows($r);
if($count == 1) {
// Create new hash
$key = hash('sha256', uniqid("", true));
// SQL query to update user record with hash value
$usql = "UPDATE registo set reset_key = '".$key."' where email = '".$email."'";
if(!mysqli_query($conn, $usql)) {
$message1 = "Error updating database!";
echo "<script>alert('$message1'); window.location.href='reset.html';</script>";
die();
}
// send link to user with generated key
$link="<a href='http://unn-w17015779.newnumyspace.co.uk/reset.php?key=".$key."'>Click To Reset password</a>";
$to = $email;
$subject = 'Reset Password';
$message = 'Click On This Link to Reset Password '.$link;
$headers = 'From: Galaxy books shop <**@gmail.com>' . "\r\n" .
'Reply-To: **@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// Send email
if(mail($to, $subject, $message, $headers)){
$message2 = "Your reset link has been sent to your email!";
echo "<script>alert('$message2'); window.location.href='home.php';</script>";
}else{
$message3 = "Failed to Recover your password, try again!";
echo "<script>alert('$message3'); window.location.href='reset.html';</script>";
}
} else {
$message4 = "User name does not exist!";
echo "<script>alert('$message4'); window.location.href='signup.html';</script>";
}
}
?>
The message appears that the email was successfully sent, but the email does not arrive?
– Woss
I tested this code on my server and it worked, but my email server is my domain and not gmail.
– user60252
exactly Anderson, appears the information that the email was sent but it does not arrive. only arrives if the email is gmail.com.
– Diana Madeira
Leo I have also come to the conclusion that has to do with the server then have come here to try to know if it can somehow control this using PHP. The server is not my domain.
– Diana Madeira