Form not sending emails

This script is sending me to the correct page once I submit but I dont receive the email and I am not sure why. The script works with my other website.

Anyone have any ideas?


if(isset($_POST['Email_Address'])) {
	if($email_to == "") {
		die("This message is for the Webmaster. Please enter your email address");
	function died($error) {
		echo "Sorry, but there were error(s) found with the form your submitted. ";
		echo "These errors appear below.<br /><br />";
		echo $error."<br /><br />";
		echo "Please go back and fix these errors.<br /><br />";
	if(!isset($_POST['Full_Name']) ||
		!isset($_POST['Email_Address']) ||
		!isset($_POST['Telephone_Number']) ||
		!isset($_POST['Your_Message'])) {
		died('We are sorry, but there appears to be a problem with the form your submitted.');		
	$email_to = ""; // your email address
	$email_subject = "Mylubbock Form"; // email subject line
	$thankyou = "index.html"; // thank you page
	$full_name = $_POST['Full_Name']; // required
	$email_from = $_POST['Email_Address']; // required
	$telephone = $_POST['Telephone_Number']; // not required
	$comments = $_POST['Your_Message']; // required
	$error_message = "";
	$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$";
  if(!eregi($email_exp,$email_from)) {
  	$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) {
	$email_message = "Form details below.\\r\
	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\
	$email_message .= "Email: ".clean_string($email_from)."\\r\
	$email_message .= "Telephone: ".clean_string($telephone)."\\r\
	$email_message .= "Message: ".clean_string($comments)."\\r\
$headers = 'From: '.$email_from."\\r\
'Reply-To: '.$email_from."\\r\
" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou");
<script>location.replace('<?php echo $thankyou;?>')</script>


<form id="contactform" action="contact.php" method="post" ><!--id=contactform-->
              <label for="Full_Name">First Name <span class="red">*</span></label>
              <input id="Full_Name" name="Full_Name" class="text" />
              <label for="Email_Address">Your email <span class="red">*</span></label>
              <input id="Email_Address" name="Email_Address" class="text" />
              <label for="company">Company</label>
              <input id="company" name="company" class="text" />
              <label for="Telephone_Number">Phone #</label>
              <input id="Telephone_Number" name="Telephone_Number" class="text" />
              <label for="Your_Message">Message <span class="red">*</span></label>
              <textarea id="Your_Message" name="Your_Message" rows="6" cols="50"></textarea>
            <input name="submit" type="submit" value="Send" />

ok, you just need to do some basic debugging

  1. start at the top of the script as specified in your form’s action attribute and add
echo 'got here'; die();

  1. run your form to check if it gets to your php script

  2. then move the above echo/die down, line by line if you have to, and add appropriate echo statements to display values of variables and then run the form again each time you move the echos.

  3. as part of 3) insert the echos in each part of conditional blocks (IF blocks) to check your code logic is correct

keep doing this until your echos show something is not right. then back track your code to fix the error.

  1. keep repeating 3) and 4) until you get to the end of your script and it works ok.

if you have a debugger, then debugguing will be easier as you can set break points and check values of variables which is essentially what the above steps are doing.

do an extremely basic test mail();