Skip to content

Commit

Permalink
Cleanner Email / Debug Error messages (#7204)
Browse files Browse the repository at this point in the history
  • Loading branch information
DawoudIO authored Dec 10, 2024
2 parents 91cfa8e + 5bf08ce commit 3770cdd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 6 additions & 3 deletions locale/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgstr ""
"#-#-#-#-# messages.po (PACKAGE VERSION) #-#-#-#-#\n"
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-08 14:45-0800\n"
"POT-Creation-Date: 2024-12-08 14:46-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -25,8 +25,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-12-08T22:45:34.521Z\n"
"PO-Revision-Date: 2024-12-08T22:45:34.522Z\n"
"POT-Creation-Date: 2024-12-08T22:46:39.101Z\n"
"PO-Revision-Date: 2024-12-08T22:46:39.102Z\n"
"Language: en\n"

msgid "Backup Database"
Expand Down Expand Up @@ -5083,6 +5083,9 @@ msgstr ""
msgid "SMTP Host is not setup, please visit the settings page"
msgstr ""

msgid "Church Email not set, please visit the settings page"
msgstr ""

msgid "Debug Email Connection"
msgstr ""

Expand Down
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');
} elseif (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 3770cdd

Please sign in to comment.