Setting up an auto response email form with php

Wondering if anyone can help.

I have an enquiry form on my website (Online Quote)

This has been running for a couple of years without any problems. I have noticed lately that I have not had any enquiries.

After testing and changing the email address for receiving the enquiry all seemed ok, suddenly all auto response has stopped.

The script that I used has been copied from an online tutorial site, so I’m not sure if it is best practice or not.

Below is the PHP script that I have used.

/*php script for gathering data from a form to an email address*/
/* subject and email variables */

	$emailSubject = 'Arrive in Style Online Quote';
	$webMaster = '';
/* gathering data variables */

	$name = $_POST['name'];
	$email = $_POST['email'];
	$telephone = $_POST['telephone'];
	$date = $_POST['date'];
	$time = $_POST['time'];
	$cars = $_POST['cars'];
	$passengers = $_POST['passengers'];
	$vehicle = $_POST['vehicle'];
	$pickup = $_POST['pickup'];
	$ceremony = $_POST['ceremony'];
	$reception = $_POST['reception'];
	$message = $_POST['message'];
	$search = $_POST['search'];
	$body = <<<EOD
Another quotation required from Arrive in Style Chauffeured Cars
name: $name <br>
email: $email <br>
phone: $telephone <br>
Date: $date <br>
Time: $time <br>
Cars: $cars <br>
Passengers: $passengers <br>
Vehicle: $vehicle <br>
Pickup: $pickup <br>
Ceremony: $ceremony <br>
Reception: $reception <br>
Message: $message <br>
Search: $search <br>

	$headers = "From: $email\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail($webMaster, $emailSubject, $body, $headers);
	/*results rendered as html */
	$theResults = <<<EOD
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Arrive in Style Chauffeured Cars</title>
<style type="text/css" media="screen">

.featurepic {


<table width="760" border="4px inset solid" bordercolor="#000000"  align="center" bgcolor="#FFFFFF">
    <table width="770" border="0">
          <td  align="center" bgcolor="#FFFFFF" bordercolorlight="#999900" ><a href="" title="Arrive in Style Wedding Cars" target="_blank"><img src="" border="0"></a>


		<table width="770" border="0">
		    <td align="left">
		      <font color="#000000">

			<p>&nbsp;</p><a href="">
			<img src="" width="200" height="165" class="featurepic" border="0"></a>


			<font color="#000000"><!--text content starts here-->

				<p>Thank you for your enquiry with Arrive in Style Chauffeured Cars.</p></font>
				<font color="#000000"><br/>

				<p>We aim to respond by email within 48 hours. </p>
<font color="#000000"><br/>
				<p>Meanwhile, if you would like to discuss the details of your event with us please telephone on</p>
                <p>01268 470643 or 07754 438581</p></font><font color="#000000"><br/>



				<p><font color="#000000">Mr Davies</font></p>
				<p align="center">To return to the Arrive in Style Website<a href=""><br/>
				<img src=""></a></p>
				<!--text content ends here-->


	<table width="770" border="0">
          <td  align="center" bgcolor="#FFFFFF" bordercolorlight="#999900" ><a href="" title="The Davies Group of Companies" target=""><img src="" border="0"></a>

As you will see this is the full script.

I hope someone can help.




echo "$theResults";


So what’s changed? Has your host imposed a limit on your server? stopped the mail daemon from working? required an SNMP interaction?

First thing for a “it stopped working” problem is to contact your hosting company and ask if something has changed.

Thanks for your reply,

I have contacted my host they say the problem is probably in the code so no real help there as yet.

Perhaps I haven’t asked the right questions.

I will go back to the host and ask your suggested questions.

Thanks for your help

If the code worked before, and you havent changed the code, and it’s stopped working, it isnt the code.


I have contacted my hosts and what seems to be the trouble is,

The emails coming from the website are being filtered as severe spam, not just spam but severe spam.

The hosts have tried sending a form from their end and it worked as spam but just went into my junk folder.

If I send a form from my IP address it registers as severe spam and doesn’t register at all.

Suggestions from my hosts is to redesign the form to not look like spam.

Would you have any suggestions ?



Your code is wide open to header injection attack - it’s likely this form has been highjacked to relay spam and your server has been blacklisted. You can check to see if this is true here:

You need to replace the code with a block that filters the fields, particularly the email field, to prevent such attacks. The PHPmailer class would be a good choice.

Another sign of spam is if the return address domain and the server’s domain do not match.

Thanks for your reply,

I have run the blacklist check and it appears I am on a couple.

My problem is I can use HTML and CSS to a reasonable standard. I am not particularly good at PHP or javascript coding, I can understand and reuse bits of code that I find useful. I have read several articles and books but still find coding a bit difficult. When you suggest the PHPmailer class, is that a book, course or something else. Sorry if I sound a bit confused.


One big thing is you are sending emails FROM a posted email. This is a big no-no called phishing. You should have an email address setup for your domain just to handle SENDING emails.
You then send emails FROM this address and add a reply-to header to contact the person. For example,

$siteemail = "";
$headers = "From: My Site Name <$siteemail>\r\n"; 
$headers .= "Reply-To: {$_POST['name']} <{$_POST['email']}>\r\n";

I would like to thank all that have tried to help me on this problem. I am sure that I understand it at the moment, but I am sure that I will get my head around it at some point.

But for now I would just like to ask for one more piece of help, could anyone recommend a good book or course that will help me understand this subject, something that would explain the principles of this particular code.



Well I highly recommend you setup the email account for your domain as I suggested before your domain is completely blacklisted for phishing, more specifically email spoofing. This IS the reason your emails are not going through.

Thanks I will be setting up the email account soon, at the moment I have taken the online quote form etc off the website and just left a normal text email contact.

This way for the time being hopefully I wont have to any disappointed visitors to the site.

I have resumed a learnable PHP course again, so head down lets get some learning done.

I really just need to understand a bit more about this subject.

Just noting: In your opening POST #1 the code has a variable set for $webMaster. I assume this was originally used for the FROM header on the “tutorial site” but somewhere along the line got changed to $_POST[‘email’].

I have shown the code exactly as I entered it into the file named form1.PHP

I copied the code line for line substituting and adding lines to suit my requirements at that time, probably three years ago.

You are probably correct in your assumption I am not really sure.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.