Php form sending copy to form email address but not to us?

the mail() function

Moderators: egami, macek, gesf

Post Reply

Mon Oct 01, 2012 2:01 pm


We have finally got a PHP Mail() form working after changing hosts, well I say working.

I've filled out the form to test it with my own email and on submission it successfully sends me a copy, but doesn't sent the business the original email submission. I've included the relevant code below can anyone tell what I'm missing please?

Code: Select all

$myFile = "log.txt";
		$log = 'Availability Check ============================'."\r\n".'Name: '.$name."\r\n".'Email: '.$email."\r\n".'Phone: '.$phone."\r\n".'Number of Cats: '.$cats."\r\n".'Arrival Date: '.$Adate."\r\n".'Collection Date: '.$Ddate."\r\n".'Days: '.$fullDays."\r\n".'Message:'."\r\n".$message."\r\n".'Heard About Us From: '.$hearabout."\r\n".'';
		$log = str_replace('&','&',$log);
		$fh = fopen($myFile, 'a') or die("can't open file");
		$stringData = "$log\n";
		fwrite($fh, $stringData);

		$to      = '';
		//$to      = '';
		$subject = 'Enquiry from: '.$name;
		$message = 'Availability Check ============================'."\r\n".'Name: '.$name."\r\n".'Email: '.$email."\r\n".'Phone: '.$phone."\r\n".'Number of Cats: '.$cats."\r\n".'Arrival Date: '.$Adate."\r\n".'Collection Date: '.$Ddate."\r\n".'Days: '.$fullDays."\r\n".'Message:'."\r\n".$message."\r\n".'Heard About Us From: '.$hearabout."\r\n".'';
		$message = str_replace('&','&',$message);
		$headers = 'From:' . "\r\n" .
			'Reply-To: '.$email.'' . "\r\n" .
			'X-Mailer: PHP/' . phpversion();

		mail($to, $subject, $message, $headers);

		$Usermessage = 'Thank you for checking availability with cats; the information below has been sent to us. We will contact you to discuss the details or alternatively, please feel free to call us.'."\r\n".$message;
		$subject = 'Checking availability with';

		if (!empty($email)) {
			mail($email, $subject, $Usermessage, $headers);
I need the form to be sent to but it just isn't doing it for some reason?

I'm with GoDaddy hosting who apparently run PHP 5.2 if that makes any difference?

Please any help would be great, its terrible not having this work on the website.


php-forum Fan User
php-forum Fan User
Posts: 974
Joined: Mon Oct 01, 2012 12:32 pm

Tue Oct 02, 2012 11:34 am

if the script is going to be hosted at godaddy, try using as your smtp host.

if you try to do that from wamp, or a local instance, it will give you 553 errrors, but once the script is being run from their server it should work fine.


Tue Oct 02, 2012 12:14 pm

Not using SMTP?

The code is sending the the customer who fills in the form to the email they put in, but just not to us.

Surely that's a coding issue not a hosting?

Post Reply