Hi, What's wrong with my code given below, I am trying to send some contact data using CURL.On the web site the "sendmail.php" file will recieve data from "contact.php" page. <?php $url = "http://www.somedomain.com/sendmail.php"; $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s curl_setopt($ch, CURLOPT_POST, 1); // set POST method curl_setopt($ch, CURLOPT_POSTFIELDS, "txtName=test&txtEmail=needmyhelptoyou@gmail.com&txtSubject=test&txtComments=test"); // add POST fields $result = curl_exec($ch); // run the whole process curl_close($ch); echo $result; ?> PHP:
echo curl_error($ch); after the curl_exec() call to print the error code received. There is a list of error codes on the libcurl site. From looking at your code, I'd allow a lot more time for a timeout than the 3 seconds you've given it. 30 seconds would be more reasonable.