$url = "google.com"; $ch = curl_init("$url"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $output = curl_exec($ch); if ($output === false || strstr ($output, "HTTP/1.1 404")){//Since server supplies a valid HTML file for missing URLS, also need to look for 404 error in output. $out['content'] .= "

URL $url in the html mail doesn't appear to exist.

"; $badlink = true; } else { $out['content'] .= "

URL $url found

"; } echo $out['content'];