From 476eb7c88e2181fbb75c3432a16d7144449c92c3 Mon Sep 17 00:00:00 2001 From: George Dawoud Date: Sun, 8 Dec 2024 14:42:49 -0800 Subject: [PATCH] Cleanner Error messages --- src/v2/routes/email.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/v2/routes/email.php b/src/v2/routes/email.php index 1b09921920..447d27049b 100644 --- a/src/v2/routes/email.php +++ b/src/v2/routes/email.php @@ -5,6 +5,7 @@ use ChurchCRM\dto\SystemURLs; use ChurchCRM\Service\MailChimpService; use ChurchCRM\Slim\Middleware\Request\Auth\AdminRoleAuthMiddleware; +use ChurchCRM\Utils\LoggerUtils; use PHPMailer\PHPMailer\PHPMailer; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; @@ -45,14 +46,18 @@ function testEmailConnectionMVC(Request $request, Response $response, array $arg $mailer = new PHPMailer(); $message = ''; - if (!empty(SystemConfig::getValue('sSMTPHost')) && !empty(ChurchMetaData::getChurchEmail())) { + if (empty(SystemConfig::getValue('sSMTPHost'))) { + $message = gettext('SMTP Host is not setup, please visit the settings page'); + } else if ( empty(ChurchMetaData::getChurchEmail())) { + $message = gettext('Church Email not set, please visit the settings page'); + } else { $mailer->IsSMTP(); $mailer->CharSet = 'UTF-8'; $mailer->Timeout = intval(SystemConfig::getValue('iSMTPTimeout')); $mailer->Host = SystemConfig::getValue('sSMTPHost'); if (SystemConfig::getBooleanValue('bSMTPAuth')) { $mailer->SMTPAuth = true; - echo 'SMTP Auth Used
'; + LoggerUtils::getAppLogger()->debug( 'SMTP Auth Used'); $mailer->Username = SystemConfig::getValue('sSMTPUser'); $mailer->Password = SystemConfig::getValue('sSMTPPass'); } @@ -63,8 +68,6 @@ function testEmailConnectionMVC(Request $request, Response $response, array $arg $mailer->addAddress(ChurchMetaData::getChurchEmail()); $mailer->Body = 'test email'; $mailer->Debugoutput = 'html'; - } else { - $message = gettext('SMTP Host is not setup, please visit the settings page'); } $pageArgs = [