I'm trying to figure out why my php mail form isn't sending an email if the email entered into the input field contains the .edu domain. I can use the form to send to the same email just fine, but if I include the full edu domain address the recipient is to reply to, nothing is sent. The format I'm referring to is "example@mail.universityname.edu", if I drop the edu or even just the "u" in the input field the email sends. I've searched around, but I'm not seeing this same issue from my searches. My php code is below. Thank you
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "something@gmail.com";
$email_subject = "Contact Form";
function died($error) {
// your error code can go here
echo "<br /> <br /> We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['date1']) ||
!isset($_POST['date2']) ||
!isset($_POST['charge']) ||
!isset($_POST['hours']) ||
!isset($_POST['subject'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$date1 = $_POST['date1']; // not required
$date2 = $_POST['date2']; //required
$charge = $_POST['charge']; //required
$hours = $_POST['hours']; //required
$subject = $_POST['subject']; // required
$error_message = "";
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
$date_exp='/^(19[5-9][0-9]|20[0-4][0-9]|2050)[-](0?[1-9]|1[0-2])[-](0?[1-9]|[12][0-9]|3[01])$/';
if(!preg_match($date_exp,$date1)) {
$error_message .= 'The first date you entered does not appear to be valid.<br />';
}
if(!preg_match($date_exp,$date2)) {
$error_message .= 'The second date you entered does not appear to be valid.<br />';
}
if(strlen($subject) < 2) {
$error_message .= 'The reason you entered is not long enough.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Employee Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "From Date: ".clean_string($date1)."\n";
$email_message .= "To Date: ".clean_string($date2)."\n";
$email_message .= "Charge To: ".clean_string($charge)."\n";
$email_message .= "Hours: ".clean_string($hours)."\n";
$email_message .= "Reason: ".clean_string($subject)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
echo '<script type="text/javascript"> document.location = "http://xx/thanks.html";</script>'
<?php
}
?>