mailtest show error msg

This commit is contained in:
lgb
2024-06-22 16:30:55 +08:00
parent 71e26e76d2
commit 678f74a17a
3 changed files with 15 additions and 6 deletions

View File

@@ -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;
}
}
}

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.12');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-06-16');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-06-22');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -20,9 +20,14 @@ if ($action == "sendmail")
EOD;
// sent_mail($email, $SITENAME, $SITEEMAIL, change_email_encode(get_langfolder_cookie(), $title), change_email_encode(get_langfolder_cookie(),$body), '', false, false, '', get_email_encode(get_langfolder_cookie()));
sent_mail($email, $SITENAME, $SITEEMAIL, $title, $body, '', false, false, '', get_email_encode(get_langfolder_cookie()));
stderr($lang_mailtest['std_success'], $lang_mailtest['std_success_note']);
// sent_mail($email, $SITENAME, $SITEEMAIL, $title, $body, '', false, false, '', get_email_encode(get_langfolder_cookie()));
try {
$toolRep = new \App\Repositories\ToolRepository();
$toolRep->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("<br/><br/><code>%s</code>", $e->getMessage()), false);
}
}
else
{