Welcome to WebmasterWorld Guest from

Forum Moderators: phranque

Message Too Old, No Replies

Being notified of particular server requests

How to have an email sent?

5:40 pm on Aug 12, 2007 (gmt 0)

10+ Year Member

I would like to be sent an email whenever a particular server request is made, such as from a particular IP address for a specific page. The notification doesn't have to be immediate; within the hour would be fine. This is on an Apache server on a Unix box. Are there scripts available to do this?
5:51 pm on Aug 12, 2007 (gmt 0)

5+ Year Member

Are you using PHP? Here is something I've used.

// create an array of watched IP addresses
$watchedIPs = array('x.x.x.x','x.x.x.x');

// check the remote address against the array of IP addresses
for($i=0, $num=sizeof($watchedIPs); $i<$num; $i++){
if(strpos($_SERVER['REMOTE_ADDR'],$watchedIPs[$i])!== false){
/* send a notification email */
7:05 pm on Aug 12, 2007 (gmt 0)

10+ Year Member

Thanks, but except for the search box my site is entirely static.

I can use PHP, but I don't know whether I could intercept the request and deal with it on the fly? Or whether I'd need to process the log file once an hour?

6:45 am on Aug 13, 2007 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Since the request is for a static page, only the web server software is "aware" of the page being requested.

Check out the capabilities of the mod actions [httpd.apache.org] module, it would be a very simple thing to write a script to do this. You could even write it in PHP and have the module execute it for you, although perl is probably more adept at command line scripting.