Skip to content

Commit

Permalink
Issue #4986 Added option to send an email when a critical error occur…
Browse files Browse the repository at this point in the history
…s. (one email per day)

Usage: Add the following to e107_config.php, replacing the email address with your own.

define('e_EMAIL_CRITICAL', 'myemail@somewhere.com');
  • Loading branch information
CaMer0n committed Mar 23, 2023
1 parent 9c3b90d commit 4d1f117
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions e107_handlers/message_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,21 @@ function show_emessage($mode, $message, $line = 0, $file = "") {
$file = null;
}

if(defined('e_EMAIL_CRITICAL'))
{
$date = date('r');
$subject = '['. $_SERVER['HTTP_HOST'].'] Critical Error';
$emailLogFile = e_LOG.'criticalErrorEmail'.date('Ymd').'.log';
if(!file_exists($emailLogFile))
{
@mail(e_EMAIL_CRITICAL, $subject, $date."\t\t". strip_tags($message));
@file_put_contents(e_LOG.'criticalErrorEmail'.date('Ymd').'.log', 'Critical Error email sent to '.e_EMAIL_CRITICAL);
}
$message = LAN_ERROR_11; // "Check log for details";
$line = null;
$file = null;
}


if(!defined('HEADERF'))
{
Expand Down

0 comments on commit 4d1f117

Please sign in to comment.