从5.6 [重复]更新到7.2后,电子邮件表单不再有效

I've searched all over the internet for help on this and couldn't find anything. Apparently I'm the only person who have encountered this problem, lol.

I have a webform on my website that has worked from the beginning. Recently the server that hosts my website informed me that support for php 5.6 will be discontinued soon, and that I would have to update to 7.2. So I did and now the email form would behave like normal, like filling it out incorrectly would show the error messages like before, filling it out correctly would lead to the thank you page like normal, but no email will be sent.

I've checked the spam folder and everything, it doesn't work. I was wondering if there is a problem with my code that 5.6 was more forgiving about that 7.2 isn't, or if there is a function within my code that is no longer supported?

Can you guys please look over my code if you have time to see what the heck is going on??

<?php

if(!isset($_POST['submit']))
{
        //This page should not be accessed directly. Need to submit the form.
        echo "error; You need to submit the form!";
}
$fname = $_POST['fname'];
$midname = $_POST['midname'];
$lname = $_POST['lname'];
$age = $_POST['age'];
$cust_email = $_POST['cust_email'];
$phone = $_POST['phone'];
$priorstudent = $_POST['priorstudent'];
$priorstudentdate = $_POST['priorstudentdate'];
$gunexperience = $_POST['gunexperience'];
$experiencedetails = $_POST['experiencedetails'];
$trainingpackage = $_POST['trainingpackage'];
$customergun = $_POST['customergun'];
$guntype = $_POST['guntype'];
$referred_by = $_POST['referred_by'];
$referred_details = $_POST['referred_details'];


//Validate first
if(empty($fname)||empty($lname)||empty($cust_email)) 
{
    echo "Full name and email are mandatory!";
    exit;
}

if(IsInjected($visitor_email))
{
    echo "Bad email value!";
    exit;
}


$email_subject = "New Form submission";
$email_body = "First Name: $fname 
 Middle Name: $midname 
 Last Name: $lname 
 Age: $age 

 Email: $cust_email 
 Phone: $phone 
 Prior Student: $priorstudent - $priorstudentdate 
 Experience: $gunexperience 
 $experiencedetails 

 Training: $trainingpackage 
 Firearm: $customergun - $guntype 

 Referred: $referred_by - $referred_details 
".

$headers = "Reply-To: $cust_email 
";
// if the url field is empty
if(isset($_POST['url']) && $_POST['url'] == ''){
  //Send the email!
  mail("ken@sflguntraining.com", $email_subject, $email_body, $visitor_email);
  //done. redirect to thank-you page.
  header('Location: thank-you.html');
}





// Function to validate against any email injection attempts
function IsInjected($str)
{
  $injections = array('(
+)',
              '(+)',
              '(\t+)',
              '(%0A+)',
              '(%0D+)',
              '(%08+)',
              '(%09+)'
              );
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str))
    {
    return true;
  }
  else
    {
    return false;
  }
}

// if url field is not empty
?>


<h1>Thanks!</h1>

We'll get back to you as soon as possible.

Sorry for pasting the entire thing, I know I'm only supposed to single out what might be the cause of the issue but the problem is I have no clue... Just so you know, the part about the blank url is kind of like a trick for autofill bots. The form itself states to leave it blank, but autofill bots should fill a url into it, which would cause the fake thank you message to show instead of referring to the actual thank you page after the email is sent. When I fill it out correctly it properly directs to the real thank you page, and if I put anything in the "url" box it'll show the fake thank you message. Everything seems to work, but no email is actually sent.

</div>