Can't remember where I found this but it works, you need to set up a cron job though;
Code:
<?php
$domain = 'example.com';
if(gethostbyname($domain) != $domain )
{
// email everything OK to be sure working
}
else
{
//send an email when it's down
$to = "[email protected]";
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = "$domain is down";
// $body = "URL is :".$url."\r\n";
$body = "The site $domain is offline now\r\n";
mail($to, $subject, $body,$headers);
}
?>