From 88f01fe1561a2bd4aeb0ec3e00e859c7782c2fab Mon Sep 17 00:00:00 2001 From: Bruno Eckhardt Date: Mon, 16 Mar 2026 13:14:32 +0100 Subject: [PATCH] update: error mailing --- WEBROOT/controller/DatabaseConnect.php | 14 +++++++++----- WEBROOT/modules/Mail.php | 10 ++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/WEBROOT/controller/DatabaseConnect.php b/WEBROOT/controller/DatabaseConnect.php index 44718a0..5c13050 100644 --- a/WEBROOT/controller/DatabaseConnect.php +++ b/WEBROOT/controller/DatabaseConnect.php @@ -35,9 +35,15 @@ function db_connect() { 'password' => 'bBHofurUJWKzPE8Z', 'database' => 'DEV', ], + 'error' => [ + 'hostaddr' => '10.233.1.244', + 'username' => 'error', + 'password' => 'bBHofurUJWKzPE8Z', + 'database' => 'DEV', + ] ]; - $enviroment = 'vpn'; + $enviroment = 'error'; mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); @@ -55,11 +61,9 @@ function db_connect() { } catch (mysqli_sql_exception $e) { - sendMail( - "ERROR: Database connection failed", + errorMail( $e->getMessage(), - (new getSpecificData())->getRequestURL(), - false + "Database Connection failed" ); throw $e; diff --git a/WEBROOT/modules/Mail.php b/WEBROOT/modules/Mail.php index 1e8f380..f9fff66 100644 --- a/WEBROOT/modules/Mail.php +++ b/WEBROOT/modules/Mail.php @@ -22,4 +22,14 @@ function sendMail($subject, $message, $url, bool $log) { (new getSpecificData())->getClientIP(), ); } +} + +function errorMail($error, $title) { + $headers = "From: bruno.eckhardt07@gmail.com\r\n"; + mail( + "bruno.eckhardt07@gmail.com",+ + "ERROR: $title", + $error->getMessage(), + $headers, + ); } \ No newline at end of file