note 39786 modified in ref.mail by aidan

From: Date: Sat, 26 Jun 2004 03:20:28 +0000
Subject: note 39786 modified in ref.mail by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-71714@lists.php.net to get a copy of this message
I use this simple function to generate VERY important error messages from my different sites. Hope somebody find it useful. Example usage: <?php //--- SNIP ---- // // here is your database checking code // if($DatabaseIsEmpty) SendSiteError("you just loose your job: database is EMPTY !",$_SERVER['SCRIPT_NAME'], __LINE__); //--- SNIP ---- ?> In your configation php file put: <?php $SITE_WEBMASTER_EMAIL="webmaster@yoursite"; function SendSiteError($ErrStr, $file='', $line='', $OutGlobal = 0){ $body ="Error message from: ".$_SERVER['SERVER_NAME']." at ".date("d/m/Y H:i:s")."\n"; $body.="While processing: ".$_SERVER['REQUEST_URI']."\n"; $body.="Error string: ".$ErrStr."\n"; if($file!='') $body.="in file : $file \n"; if($line!='') $body.="line : $line \n"; if($OutGlobal) $body.="variable:".var_export($GLOBALS,true)."\n"; $body.="------------------------------\n"; $dest=$GLOBALS['SITE_WEBMASTER_EMAIL']; if($dest) mail($dest,"Error msg from: ".$_SERVER['SERVER_NAME'],$body); } ?> --was-- I use this simple function to generate VERY important error messages from my different sites. Hope somebody find it useful. Example usage: //--- SNIP ---- // // here is your database checking code // if($DatabaseIsEmpty) SendSiteError("you just loose your job: database is EMPTY !",$_SERVER['SCRIPT_NAME'], __LINE__); //--- SNIP ---- In your configation php file put: //--- SNIP ---- $SITE_WEBMASTER_EMAIL="webmaster@yoursite"; function SendSiteError($ErrStr, $file='', $line='', $OutGlobal = 0){ $body ="Error message from: ".$_SERVER['SERVER_NAME']." at ".date("d/m/Y H:i:s")."\n"; $body.="While processing: ".$_SERVER['REQUEST_URI']."\n"; $body.="Error string: ".$ErrStr."\n"; if($file!='') $body.="in file : $file \n"; if($line!='') $body.="line : $line \n"; if($OutGlobal) $body.="variable:".var_export($GLOBALS,true)."\n"; $body.="------------------------------\n"; $dest=$GLOBALS['SITE_WEBMASTER_EMAIL']; if($dest) mail($dest,"Error msg from: ".$_SERVER['SERVER_NAME'],$body); } //--- SNIP ---- http://php.net/manual/en/ref.mail.php

« previous php.notes (#71714) next »