From 678f74a17a2d3269538e02f7061f6e37a2193ff9 Mon Sep 17 00:00:00 2001
From: lgb <353856593@qq.com>
Date: Sat, 22 Jun 2024 16:30:55 +0800
Subject: [PATCH] mailtest show error msg
---
app/Repositories/ToolRepository.php | 8 ++++++--
include/constants.php | 2 +-
public/mailtest.php | 11 ++++++++---
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/app/Repositories/ToolRepository.php b/app/Repositories/ToolRepository.php
index d84518fd..69de55ba 100644
--- a/app/Repositories/ToolRepository.php
+++ b/app/Repositories/ToolRepository.php
@@ -316,7 +316,7 @@ class ToolRepository extends BaseRepository
* @param $body
* @return bool
*/
- public function sendMail($to, $subject, $body): bool
+ public function sendMail($to, $subject, $body, $exception = false): bool
{
$log = "[SEND_MAIL]";
$factory = new EsmtpTransportFactory();
@@ -353,7 +353,11 @@ class ToolRepository extends BaseRepository
return true;
} catch (\Throwable $e) {
do_log("$log, fail: " . $e->getMessage() . "\n" . $e->getTraceAsString(), 'error');
- return false;
+ if ($exception) {
+ throw $e;
+ } else {
+ return false;
+ }
}
}
diff --git a/include/constants.php b/include/constants.php
index bbcbb174..37608b46 100644
--- a/include/constants.php
+++ b/include/constants.php
@@ -1,6 +1,6 @@
sendMail($email, $title, $body, true);
+ stderr($lang_mailtest['std_success'], $lang_mailtest['std_success_note']);
+ } catch (\Throwable $e) {
+ stderr($lang_functions['std_error'], $lang_functions['text_unable_to_send_mail'] . sprintf("
%s", $e->getMessage()), false);
+ }
}
else
{