Email not sending if coming from yahoo or aol user

I have a contact form on a website and it works fine, aside from a few mail providers seeming to reject sending the Email. If I put example@gmail. com it will send, if I put example@fullsail. com it will send, but if I put either example@yahoo. com or example@aol. com it doesn’t send out the Email. Any idea why this may be?

<?php
if(isset($_POST['email'])) {
    
    $email_to = "email@gmail.com";
     
     
    function died($error) {
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo '<p style="color: #EB4D4D;">' . $error . '</p><br /><br />';
        echo "Please go back and fix these errors.<br /><br />";
        echo '<button onclick="history.go(-1);" style="">Go Back </button>';
        die();
    }
     
    if(!isset($_POST['name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['type']) ||
        !isset($_POST['message'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
    }
     
    $name = $_POST['name']; 
    $email = $_POST['email']; 
    $type = $_POST['type']; 
    $message = $_POST['message']; 
     
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
    if(!preg_match($email_exp,$email)) {
        $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
    }
    $string_exp = "/^[A-Za-z .'-]+$/";
    if(!preg_match($string_exp,$name)) {
        $error_message .= 'The Name you entered does not appear to be valid.<br />';
    }
    if(strlen($message) < 2) {
        $error_message .= 'The Message you entered do not appear to be valid.<br />';
    }
    $arrayVals = ["Appointments", "Payments", "Information", "Business Matters", "Other"]; 
    if(!in_array($type, array_keys($arrayVals))) {
        $error_message .= 'You must select an option for the Inquiry Type.<br />';
    }
    
    if(strlen($error_message) > 0) {
        died($error_message);
    }
    $email_message = "You have received a new inquiry from " . $name . " .\nYou can view the contents below.\n\n";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
     
    $email_message .= "Name: ".clean_string($name)."\n";
    $email_message .= "Email: ".clean_string($email)."\n";
    $email_message .= "Inquiry Type: ".clean_string($arrayVals[$type])."\n";
    $email_message .= "Message: ".clean_string($message)."\n";
    
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $arrayVals[$type] . " from " . $name, $email_message, $headers);  
?>

<h1>Thank you for contacting us. We will be in touch with you very soon!</h1>
<p>You will be redirected in <span id="counter">5</span> second(s).</p>
<script type="text/javascript">
var counter = 5;
setInterval(function() {
    counter--;
    if(counter < 0) {
        window.location = 'index.html';
    } else {
        document.getElementById("counter").innerHTML = counter;
         }
}, 1000);
</script>
 
<?php
}
die();
?>

We are blacklisted by some webhosting companies because we were abused by spammers.
Please upgrade :slight_smile: