PHP- only sends links to emails from gmail

0

I have the following code that sends a password reset link, but the problem here is that if the email requesting new password for gmail.com sends without any problem but if it is another email such as hotmail.com etc. simply does not send any links.

<?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>";
    }
}
?>
    
asked by anonymous 20.05.2017 / 15:42

0 answers