I am writing a script to monitor the existance of a webserver and have a function to send a value to a script on another server for processing - the value gets emailed).

The general aim is to use fsockopen and post the variable and thus went a nd built a very simple function to do this which didn't work. So after looking round a few forums, found this:

Code:
   function alert($data)
   	{
   		$host = "www.mywebsite.net";
   		$path = "monitor/capture.php";
   		
   		$http_response = "";
   		$content_length = strlen($data);
   		
   		$fp = fsockopen($host, 80);
   		fputs($fp, "POST $path HTTP/1.1\r\n");
   		fputs($fp, "Host: $host\r\n");
   		fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
   		fputs($fp, "Content-Length: $content_length\r\n");
   		fputs($fp, "Connection: close\r\n\r\n");
   		fputs($fp, $data);
   		while (!feof($fp))
   		{
   		$http_response .= fgets($fp, 128);
   		}
   		fclose($fp);
   		
   		return $http_response;
   	}
 
 alert($data);
And capture.php (the email script):

Code:
   $to = "name@website.com";
   $message = $_POST['message'];
   
   $subject = "test";
   
   if(mail($to, $subject, $message))
   	{
   	echo "Mail sent";
   	}
   else
   	{
   	echo "Mail not sent";
   	}
All looks pretty simple but an email never gets sent so I suspect the post function (called alert) doesn't work although no error messages are generated during running.

All I need to do is send a string to capture.php from the original script without using forms, or having a user click on anything. I know it is possible and allegedly by using that first function. If anyone can help shed some light, it would be appreciated!!

Thanks!