Online subission forms not sending emails of submitted info

About a year ago, I had a similar issue except then system would crash after pressing Submit. The issue was caused because of PHP 8 incompatibility problems. However, got the coding to fix all of that and things worked good again and with PHP 8. But now something new is happening. Now, when Submit is pressed, system doesn't crash and goes to the after submission screen like its supposed to. Everything appears to be working fine except for one thing. No emails are being received. Last on line submission form I received was on 2/6/2024. No coding was changed at all, just nothing sends at all. I tested multiple on line submission forms on several websites. Same thing, nothing is sending. The coding I used to fix everything before is the same on all the on-line submission pages. It appears to be an issue with PHP. The coding for 1 of these pages is below.
`

<?php
// grab recaptcha library
// require_once "recaptchalib.php";
// foreach ($_POST as $key => $value) {
    //echo '<p><strong>' . $key.':</strong> '.$value.'</p>';
  //}
// your secret key
$recaptcha_secret_key = "6LeW4RQUAAAAAJ4NvgWIKJc4b-AeKp6LcLFCFQoS";

// empty response
$recaptcha_response = $_POST['g-recaptcha-response'];

$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
$recaptcha_data = array(
    'secret' => $recaptcha_secret_key,
    'response' => $recaptcha_response
);

$recaptcha_options = array(
    'http' => array(
        'header' => "Content-type: application/x-www-form-urlencoded\r\n",
        'method' => 'POST',
        'content' => http_build_query($recaptcha_data)
    )
);

$recaptcha_context = stream_context_create($recaptcha_options);
$recaptcha_result = file_get_contents($recaptcha_url, false, $recaptcha_context);
$recaptcha_json = json_decode($recaptcha_result);

if ($recaptcha_json->success) {
    // ReCaptcha validation successful, process the form submission
    // Your form processing code goes here

$subject = "Showing Scheduling";
$message = "RadiantNewHorizonHomes.com Showing Scheduling" . "\r\n" . "\r\n" .
"Name: " . $_POST['ShowingName'] . "\r\n" .

"Phone Number : " . $_POST['ShowingPhone1'] . "\r\n" .

"E-mail Address: " . $_POST['ShowingEmail'] . "\r\n" .
"Properties wants to see: " . $_POST['ShowingHomes'] . "\r\n" .
"Date(s)/Time(s) wants to see them: " . $_POST['ShowingTimes'] . "\r\n" .






"Questions or Comments: " . $_POST['ShowingQuestions'] . "\r\n" .

"How Heard About Us: " . $_POST['ShowingHearing'] . "\r\n" .

$from = $_POST['ShowingEmail'];
$headers = "From: $from" . "\r\n";

$to = "david.tigner@radiantnewhorizonhomes.com";
mail($to,$subject,$message,$headers);
$to = "Agents1@radiantnewhorizonhomes.com";
mail($to,$subject,$message,$headers);

} else {
    // ReCaptcha validation failed, display an error message or take appropriate action
    // Example: redirect back to the form page with an error message
    header('Location: form.php?error=recaptcha');
    exit();
}   

?>

`

`

ReCaptcha v3 coding placement

I am trying to upgrade from ReCaptcha v1 (in use and working good since 2017) to ReCaptcha v3 as ReCaptcha is not compatible with any of the PHP v8's. I started setting it up (got site and secret keys) and coding for 2 versions of ReCaptcha v3 (1. Automatically bind the challenge and 2. Programmitically invoke the challenge). I like 2. better. Anyway, the coding format for these 2 ReCaptcha v3's are different than what is currently in use on the HTML front side of my on-line submission pages. The coding for 1. & 2. are below. The Curly braces and tab stops (4+ spaces) were removed from the coding to avoid getting the following message: 'Curly braces and tab stops (4+ spaces) may only be used when posting code.'. Each of the 2 versions below has 3 parts. Only part 1 of both (Load the JavaScript API) is the same coding format as the original.

I have a few questions:

  1. Where in the program file would the coding listed under both part 2's go ? (e.g. Add a callback function to handle the token & Call grecaptcha.execute on each action you wish to protect.) As they are <script> functions it looks like they may go in the <head> section with the other <script> stuff.

  2. Where in the program file would the coding listed under both 1. part 3 go ? (e.g. Add attributes to your html button) In the original, in the <body> section in the part where the ReCaptcha appears on the screen is the following: <div align="center" class="g-recaptcha" data-sitekey="(site key code)"></div>

  3. Under 2. part 3: Send the token immediately to your backend with the request to verify (/recaptcha/docs/verify), how is this done ? (I haven't looked at the PHP code in the backend side file yet. Want to get the front end HTML stuff set first then I'll see about configuring ReCaptcha v3 in the PHP file)

ReCaptcha v3 Coding:

  1. Automatically bind the challenge to a button

The easiest method for using reCAPTCHA v3 on your page is to include the necessary JavaScript resource and add a few attributes to your html button.

Part 1 - Load the JavaScript API.

<script src="https://www.google.com/recaptcha/api.js"></script>

Part 2 - Add a callback function to handle the token.

<script>
function onSubmit(token)document.getElementById("demo-form").submit();
</script>

Part 3 - Add attributes to your html button.

<button class="g-recaptcha" 
        data-sitekey="reCAPTCHA_site_key" 
        data-callback='onSubmit' 
        data-action='submit'>Submit</button>
  1. Programmatically invoke the challenge

If you wish to have more control over when reCAPTCHA runs, you can use the execute method in grecaptcha object. To do this, you need to add a render parameter to the reCAPTCHA script load.

Part 1 - Load the JavaScript API with your sitekey.

<script src="https://www.google.com/recaptcha/api.js?render=reCAPTCHA_site_key"></script>

Part 2 - Call grecaptcha.execute on each action you wish to protect.

<script>
function onClick(e)
e.preventDefault();
grecaptcha.ready(function()
grecaptcha.execute('reCAPTCHA_site_key', {action: 'submit'}).then(function(token)
// Add your logic to submit to your backend server here.););
</script>

Part 3 - Send the token immediately to your backend with the request to verify.

Online submission fprms not working with PHP v8

My online submission pages no longer work after upgrading to PHP v8. After pressing Submit, screen then turns white and no email sent with the submitted info. Screen is not supposed to turn white. After switching back to PHP 7.4, everything worked normally again. I have many online submission pages which all use the same code. The code never had any issues with any version of PHP dating back to 2011. Attached is one of the PHP programs. How can it be edited so it will work with PHP v8 ?

My online submission pages no longer work after upgrading to PHP v8. After pressing Submit, screen then turns white and no email sent with the submitted info. Screen is not supposed to turn white. After switching back to PHP 7.4, everything worked normally again. I have many online submission pages which all use the same code. The code never had any issues with any version of PHP dating back to 2011. Attached is one of the PHP programs. How can it be edited so it will work with PHP v8 ?
<?php
// grab recaptcha library
require_once "recaptchalib.php"; 
// foreach ($_POST as $key => $value) {
    //echo '<p><strong>' . $key.':</strong> '.$value.'</p>';
  // }
// your secret key
$secret = "6LeW4RQUAAAAAJ4NvgWIKJc4b-AeKp6LcLFCFQoS"; 

// empty response
$response = null; 

// check secret key
$reCaptcha = new ReCaptcha($secret); 
// if submitted check response
if ($_POST["g-recaptcha-response"]) { 
   $response = $reCaptcha->verifyResponse( 
          $_SERVER["REMOTE_ADDR"], 
       $_POST["g-recaptcha-response"] 
    ); 
} 
if ($response != null && $response->success) { 

$subject = "Showing Scheduling";
$message = "RadiantNewHorizonHomes.com Showing Scheduling" . "\r\n" . "\r\n" .
"Name: " . $_POST['ShowingName'] . "\r\n" .

"Phone Number : " . $_POST['ShowingPhone1'] . "\r\n" .

"E-mail Address: " . $_POST['ShowingEmail'] . "\r\n" .
"Properties wants to see: " . $_POST['ShowingHomes'] . "\r\n" .
"Date(s)/Time(s) wants to see them: " . $_POST['ShowingTimes'] . "\r\n" .






"Questions or Comments: " . $_POST['ShowingQuestions'] . "\r\n" .

"How Heard About Us: " . $_POST['ShowingHearing'] . "\r\n" .

$from = $_POST['ShowingEmail'];
$headers = "From: $from" . "\r\n";

$to = "david.tigner@radiantnewhorizonhomes.com";
mail($to,$subject,$message,$headers);


} else { } 

?>