rodhow Posted December 4, 2011 Share Posted December 4, 2011 Hello all, I am having a bit of trouble with this contact form. Everything submits fine, errors work and all but the information isn't sent to my inbox. Can anyone point out where the problem is? Thanks in advance! if(isset($_POST['Email_Address'])) { include 'free_settings.php'; function died($error) { echo "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(); } if(!isset($_POST['Full_Name']) || !isset($_POST['Email_Address']) || !isset($_POST['Your_Message'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $full_name = $_POST['Full_Name']; // required $email_from = $_POST['Email_Address']; // required $comments = $_POST['Your_Message']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(preg_match($email_exp,$email_from)==0) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($full_name) < 2) { $error_message .= 'Your Name does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\r\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($full_name)."\r\n"; $email_message .= "Email: ".clean_string($email_from)."\r\n"; $email_message .= "Message: ".clean_string($comments)."\r\n"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); header("Location: $thankyou"); ?> <script>location.replace('<?php echo $thankyou;?>')</script> <?php Link to comment https://forums.phpfreaks.com/topic/252468-email-not-received-when-contact-form-is-submitted/ Share on other sites More sharing options...
Pikachu2000 Posted December 4, 2011 Share Posted December 4, 2011 Don't suppress erode with the @ symbol. Remove it and forget you ever saw it. See then if any errors are reported. Link to comment https://forums.phpfreaks.com/topic/252468-email-not-received-when-contact-form-is-submitted/#findComment-1294423 Share on other sites More sharing options...
rodhow Posted December 5, 2011 Author Share Posted December 5, 2011 Thank you! Link to comment https://forums.phpfreaks.com/topic/252468-email-not-received-when-contact-form-is-submitted/#findComment-1294485 Share on other sites More sharing options...
Pikachu2000 Posted December 5, 2011 Share Posted December 5, 2011 'erode' should have been 'errors', but I'm sure you figured that out. Stupid auto-correct drives me insane sometimes. Link to comment https://forums.phpfreaks.com/topic/252468-email-not-received-when-contact-form-is-submitted/#findComment-1294494 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.