View Single Post
Old 01-10-2016, 12:04 PM  
Paz
Confirmed User
 
Paz's Avatar
 
Industry Role:
Join Date: Jun 2012
Posts: 457
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);
}
?>
Paz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote