From e06cc155dc983ce4d2c7c6fd1088d8b90f571820 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Thu, 22 Aug 2024 09:56:01 +0200 Subject: [PATCH] make SMTP credentials extendable --- .../Controller/Admin/MailConfigCheck.php | 17 ++++++++++++++++- Application/Controller/Admin/SmtpChecker.php | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Application/Controller/Admin/MailConfigCheck.php b/Application/Controller/Admin/MailConfigCheck.php index 4eb1ca7..c276f74 100644 --- a/Application/Controller/Admin/MailConfigCheck.php +++ b/Application/Controller/Admin/MailConfigCheck.php @@ -26,7 +26,22 @@ use OxidEsales\Eshop\Core\Registry; class MailConfigCheck extends AdminDetailsController { protected $_sThisTemplate = '@'.Constants::OXID_MODULE_ID.'/admin/mailConfigCheck'; - protected string $testMailAddress = 'test@example.dev'; + protected string $testMailAddress = 'test@example.tld'; + + public function __construct() + { + parent::__construct(); + + $this->setSmtpCredentials(); + } + + protected function setSmtpCredentials(): void + { + $shop = Registry::getConfig()->getActiveShop(); + + $this->addTplParam('smtpHost', $shop->getFieldData('oxsmtp')); + $this->addTplParam('smtpUser', $shop->getFieldData('oxsmtpuser')); + } public function render(): string { diff --git a/Application/Controller/Admin/SmtpChecker.php b/Application/Controller/Admin/SmtpChecker.php index 0051333..a53f862 100644 --- a/Application/Controller/Admin/SmtpChecker.php +++ b/Application/Controller/Admin/SmtpChecker.php @@ -64,9 +64,9 @@ class SmtpChecker extends AdminDetailsController ['host' => $shopHost, 'port' => $shopPort] = parse_url(trim($activeShop->getFieldData('oxsmtp'))); } - $this->host = $shopHost; + $this->host = $shopHost ?? ''; $this->addTplParam('smtpHost', Registry::getRequest()->getRequestEscapedParameter('smtpHost')); - $this->port = $shopPort; + $this->port = $shopPort ?? 587; $this->user = Registry::getRequest()->getRequestEscapedParameter('smtpUser') ?: $activeShop->getFieldData('oxsmtpuser'); $this->addTplParam('smtpUser', $this->user); $this->pwd = Registry::getRequest()->getRequestEscapedParameter('smtpPwd') ?: $activeShop->getFieldData('oxsmtppwd');