My php file for registering
<?php
    require("password.php");
    $connect = mysqli_connect("localhost", "root", "", "accounts");
    $first_name = $_POST["first_name"];
    $last_name = $_POST["last_name"];
    $email = $_POST["email"];
    $password = $_POST["password"];
     function registerUser() {
        global $connect, $first_name, $last_name, $email, $password;
        $passwordHash = password_hash($password, PASSWORD_DEFAULT);
        $statement = mysqli_prepare($connect, "INSERT INTO users (first_name, last_name, email, password, hash, active) VALUES (?, ?, ?, ?, 123, 0)");
        mysqli_stmt_bind_param($statement, "ssss", $first_name, $last_name, $email, $passwordHash);
        mysqli_stmt_execute($statement);
        mysqli_stmt_close($statement);
        // Send registration confirmation link (verify.php)
        $to      = $email;
        $subject = 'Account Verification ( Name.com )';
        $message_body = '
        Hello '.$first_name.',
        Thank you for signing up!
        Please click this link to activate your account:
        http://localhost/accounts/verify.php?email='.$email.'&hash='.'123';  
        mail( $to, $subject, $message_body );
    }
    function emailAvailable() {
        global $connect, $email;
        $statement = mysqli_prepare($connect, "SELECT * FROM users WHERE email = ?"); 
        mysqli_stmt_bind_param($statement, "s", $email);
        mysqli_stmt_execute($statement);
        mysqli_stmt_store_result($statement);
        $count = mysqli_stmt_num_rows($statement);
        mysqli_stmt_close($statement); 
        if ($count < 1){
            return true;            
        }else {
            return false; 
        }
    }
    $success = '';
    $response = array();
    $response["success"] = false;
    if (emailAvailable()){
        registerUser();
        mysqli_set_charset($con,"utf8");
        $response["success"] = true;
        }
    echo json_encode($response);
?>
After adding the code
    // Send registration confirmation link (verify.php)
    $to      = $email;
    $subject = 'Account Verification ( Name.com )';
    $message_body = '
    Hello '.$first_name.',
    Thank you for signing up!
    Please click this link to activate your account:
    http://localhost/accounts/verify.php?email='.$email.'&hash='.'123';  
    mail( $to, $subject, $message_body );
there is no response from my application from
    $response["success"] = true;
    }
    echo json_encode($response);
however $response["success"] = false; still works and outputs a false value.
I am looking for a way to implement the mailing system in such a way that it does not affect the $response["success"] = true;
Will appreciate any guidance from anyone that can help thank you!
 
    