note 39786 added to ref.mail
| From: | dan at rn2 dot php dot net | Date: | Tue, 10 Feb 2004 16:58:22 +0000 |
| Subject: | note 39786 added to ref.mail | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64967@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:
//--- 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 ----
----
Manual Page -- http://www.php.net/manual/en/ref.mail.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39786
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39786&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39786&report=yes
Search -- http://master.php.net/manage/user-notes.php