Skip to content

Commit

Permalink
Cleanner Error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
DawoudIO committed Dec 8, 2024
1 parent b483704 commit 476eb7c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/v2/routes/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 </br>';
LoggerUtils::getAppLogger()->debug( 'SMTP Auth Used');
$mailer->Username = SystemConfig::getValue('sSMTPUser');
$mailer->Password = SystemConfig::getValue('sSMTPPass');
}
Expand All @@ -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 = [
Expand Down

0 comments on commit 476eb7c

Please sign in to comment.