diff --git a/Application/Controller/Admin/MailCheckBase.php b/Application/Controller/Admin/MailCheckBase.php
new file mode 100644
index 0000000..daff894
--- /dev/null
+++ b/Application/Controller/Admin/MailCheckBase.php
@@ -0,0 +1,40 @@
+
+ * @link https://www.oxidmodule.com
+ */
+
+declare(strict_types=1);
+
+namespace D3\MailConfigChecker\Application\Controller\Admin;
+
+use OxidEsales\Eshop\Application\Controller\Admin\AdminController;
+
+class MailCheckBase extends AdminController
+{
+ protected $_sThisTemplate = 'mailCheckBase.tpl';
+
+ /**
+ * @return string
+ */
+ public function render(): string
+ {
+ $this->addTplParam('sListClass', MailCheckMenu::class);
+ $this->addTplParam('sMainClass', setMainController::class);
+
+ $this->_hasListItems = false;
+
+ return parent::render();
+ }
+}
diff --git a/Application/Controller/Admin/MailCheckMenu.php b/Application/Controller/Admin/MailCheckMenu.php
new file mode 100644
index 0000000..26ea067
--- /dev/null
+++ b/Application/Controller/Admin/MailCheckMenu.php
@@ -0,0 +1,33 @@
+
+ * @link https://www.oxidmodule.com
+ */
+
+declare(strict_types=1);
+
+namespace D3\MailConfigChecker\Application\Controller\Admin;
+
+use OxidEsales\Eshop\Application\Controller\Admin\AdminListController;
+
+class MailCheckMenu extends AdminListController
+{
+ protected $_sThisTemplate = 'mailCheckMenu.tpl';
+
+ public function render()
+ {
+ $this->addTplParam('noOXIDCheck', true);
+ return parent::render();
+ }
+}
diff --git a/Application/Controller/Admin/MailConfigCheck.php b/Application/Controller/Admin/MailConfigCheck.php
new file mode 100644
index 0000000..57dcc69
--- /dev/null
+++ b/Application/Controller/Admin/MailConfigCheck.php
@@ -0,0 +1,154 @@
+
+ * @link http://www.oxidmodule.com
+ */
+
+namespace D3\MailConfigChecker\Application\Controller\Admin;
+
+use Assert\Assert;
+use Assert\InvalidArgumentException;
+use D3\MailConfigChecker\Application\Model\Exception\d3TranslatableLazyAssertionException;
+use Mika56\SPFCheck\DNS\DNSRecordGetter;
+use Mika56\SPFCheck\Model\Query;
+use Mika56\SPFCheck\Model\Result;
+use Mika56\SPFCheck\SPFCheck;
+use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
+use OxidEsales\Eshop\Application\Model\Shop;
+use OxidEsales\Eshop\Core\Email;
+use OxidEsales\Eshop\Core\Registry;
+
+class MailConfigCheck extends AdminDetailsController
+{
+ protected $_sThisTemplate = 'mailConfigCheck.tpl';
+
+ public function render()
+ {
+ $this->checkDataAreSet();
+ $this->addTplParam('shop', Registry::getConfig()->getActiveShop());
+
+ return parent::render();
+ }
+
+ protected function checkDataAreSet()
+ {
+ try {
+ /** @var Shop $shop */
+ $shop = Registry::getConfig()->getActiveShop();
+ $lang = Registry::getLang();
+
+ Assert::lazy()
+ ->setExceptionClass(d3TranslatableLazyAssertionException::class)
+ ->that( $shop->getFieldData( 'oxsmtp' ), $lang->translateString('SHOP_MAIN_SMTPSERVER') )
+ ->notBlank( $lang->translateString('D3_ASSERTIONS_NOTSET') )
+ ->regex( '/.*:(587|2525)$/m', $lang->translateString('D3_ASSERTIONS_NOPORT') )
+ ->that( 'cloud1-vm279.de-nserver.de:5', $lang->translateString('SHOP_MAIN_SMTPSERVER') )
+ ->notBlank( $lang->translateString('D3_ASSERTIONS_NOTSET') )
+ ->regex( '/.*:(587|2525)$/m', $lang->translateString('D3_ASSERTIONS_NOPORT') )
+ ->that( $shop->getFieldData( 'oxsmtpuser' ), $lang->translateString('SHOP_MAIN_SMTPUSER') )
+ ->notBlank( $lang->translateString('D3_ASSERTIONS_NOTSET') )
+ ->that( $shop->getFieldData( 'oxsmtppwd' ), $lang->translateString('SHOP_MAIN_SMTPPASSWORD') )
+ ->notBlank( $lang->translateString('D3_ASSERTIONS_NOTSET') )
+ ->that( $shop->getFieldData( 'oxinfoemail' ), $lang->translateString('SHOP_MAIN_INFOEMAIL') )
+ ->email( $lang->translateString('D3_ASSERTIONS_NOTSET') )
+ ->that( $shop->getFieldData( 'oxorderemail' ), $lang->translateString('SHOP_MAIN_ORDEREMAIL') )
+ ->email( $lang->translateString('D3_ASSERTIONS_NOTSET') )
+ ->that( $shop->getFieldData( 'oxowneremail' ), $lang->translateString('SHOP_MAIN_OWNEREMAIL') )
+ ->email( $lang->translateString('D3_ASSERTIONS_NOTSET') )
+ ->verifyNow();
+ } catch (InvalidArgumentException $e) {
+ Registry::getUtilsView()->addErrorToDisplay(nl2br($e->getMessage()));
+ }
+ }
+
+ public function checkConfiguration()
+ {
+ dumpvar('');
+ dumpvar('');
+ dumpvar('');
+ dumpVar('');
+ $this->useSmtp();
+ $this->checkSpf();
+ }
+
+ protected function useSmtp()
+ {
+ try {
+ echo "
Mailer Check
";
+ $mail = oxNew( Email::class );
+ $mail->setRecipient( 'test@example.com' );
+ $mail->setBody('.');
+ $mail->send();
+ dumpvar( 'Shop sendet ueber '.ucfirst($mail->getMailer()) );
+ } catch (\Exception $e) {
+ dumpvar($e->getMessage());
+ }
+ }
+
+ protected function checkSpf()
+ {
+ echo "SPF Check
";
+ $mailDomains = $this->getMailDomains();
+ array_walk(
+ $mailDomains,
+ function($domain) {
+ dumpvar(''.$domain.'');
+ $this->checkSpfByDomain($domain);
+ }
+ );
+ }
+
+ protected function checkSpfByDomain($domain)
+ {
+ $checker = new SPFCheck(new DNSRecordGetter());
+ $query = new Query('', $domain);
+
+ $result = $checker->getResult($query);
+ if (in_array(
+ $result->getResult(),
+ [Result::FAIL, Result::NEUTRAL, Result::PASS, Result::SOFTFAIL]
+ )) {
+ dumpvar('SPF is set');
+ } elseif (Result::NONE) {
+ dumpvar('SPF missing');
+ } else {
+ dumpvar('error determine SPF record');
+ }
+
+ if ($record = $result->getRecord()) {
+ dumpvar($record->getRawRecord());
+ }
+ }
+
+ protected function getMailDomains()
+ {
+ return
+ array_filter(
+ array_unique(
+ array_map(
+ function($mailAddress) {
+ $mailAddress = trim($mailAddress);
+ return strstr($mailAddress, '@') ?
+ array_pop(explode('@', $mailAddress)) :
+ '';
+ },
+ [
+ Registry::getConfig()->getActiveShop()->getFieldData('oxinfoemail'),
+ Registry::getConfig()->getActiveShop()->getFieldData('oxorderemail'),
+ Registry::getConfig()->getActiveShop()->getFieldData('oxowneremail'),
+ ]
+ )
+ )
+ );
+
+ }
+}
\ No newline at end of file
diff --git a/de/translations.php b/Application/Controller/Admin/MailTester.php
similarity index 67%
rename from de/translations.php
rename to Application/Controller/Admin/MailTester.php
index 998aa50..c3f1879 100644
--- a/de/translations.php
+++ b/Application/Controller/Admin/MailTester.php
@@ -13,6 +13,11 @@
* @link http://www.oxidmodule.com
*/
-return [
- 'MXMAILCHECK' => "Mail Check"
-];
\ No newline at end of file
+namespace D3\MailConfigChecker\Application\Controller\Admin;
+
+use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
+
+class MailTester extends AdminDetailsController
+{
+ protected $_sThisTemplate = 'mailTester.tpl';
+}
\ No newline at end of file
diff --git a/Application/Controller/Admin/SmtpChecker.php b/Application/Controller/Admin/SmtpChecker.php
index 92e79b6..b0d5233 100644
--- a/Application/Controller/Admin/SmtpChecker.php
+++ b/Application/Controller/Admin/SmtpChecker.php
@@ -13,7 +13,7 @@
declare(strict_types=1);
-namespace D3\SmtpChecker\Application\Controller\Admin;
+namespace D3\MailConfigChecker\Application\Controller\Admin;
use Assert\Assert;
use Assert\InvalidArgumentException;
@@ -85,7 +85,6 @@ class SmtpChecker extends AdminDetailsController
public function sendMail()
{
try {
- $this->checkDataAreSet();
$this->hostIsAvailable();
$this->connect();
$this->auth();
diff --git a/Application/Model/Exception/d3TranslatableLazyAssertionException.php b/Application/Model/Exception/d3TranslatableLazyAssertionException.php
new file mode 100644
index 0000000..e34e75c
--- /dev/null
+++ b/Application/Model/Exception/d3TranslatableLazyAssertionException.php
@@ -0,0 +1,35 @@
+
+ * @link http://www.oxidmodule.com
+ */
+
+namespace D3\MailConfigChecker\Application\Model\Exception;
+
+use Assert\LazyAssertionException;
+use OxidEsales\Eshop\Core\Registry;
+
+class d3TranslatableLazyAssertionException extends LazyAssertionException
+{
+ public static function fromErrors(array $errors): self
+ {
+ $text = Registry::getLang()->translateString('D3_ASSERTIONS_FAILED');
+ $message = \sprintf($text, \count($errors))."\n";
+
+ $i = 1;
+ foreach ($errors as $error) {
+ $message .= \sprintf("%d) %s: %s\n", $i++, $error->getPropertyPath(), $error->getMessage());
+ }
+
+ return new static($message, $errors);
+ }
+}
\ No newline at end of file
diff --git a/Application/views/en/module_lang.php b/Application/views/admin/de/module_lang.php
similarity index 100%
rename from Application/views/en/module_lang.php
rename to Application/views/admin/de/module_lang.php
diff --git a/Application/views/en/translations.php b/Application/views/admin/de/translations.php
similarity index 100%
rename from Application/views/en/translations.php
rename to Application/views/admin/de/translations.php
diff --git a/Application/views/admin/en/translations.php b/Application/views/admin/en/translations.php
new file mode 100644
index 0000000..a697ca0
--- /dev/null
+++ b/Application/views/admin/en/translations.php
@@ -0,0 +1,5 @@
+ 'UTF-8',
+];
diff --git a/Application/views/admin/tpl/mailTester.tpl b/Application/views/admin/tpl/mailTester.tpl
new file mode 100644
index 0000000..d4b2f07
--- /dev/null
+++ b/Application/views/admin/tpl/mailTester.tpl
@@ -0,0 +1,19 @@
+[{include file="headitem.tpl" title="d3mxd3cleartmp"|oxmultilangassign}]
+
+[{if $readonly}]
+ [{assign var="readonly" value="readonly disabled"}]
+[{else}]
+ [{assign var="readonly" value=""}]
+[{/if}]
+
+
+...
+
+[{include file="bottomnaviitem.tpl"}]
+
+[{include file="bottomitem.tpl"}]
\ No newline at end of file
diff --git a/Application/views/admin/tpl/mailcheckbase.tpl b/Application/views/admin/tpl/mailcheckbase.tpl
new file mode 100644
index 0000000..aa744c3
--- /dev/null
+++ b/Application/views/admin/tpl/mailcheckbase.tpl
@@ -0,0 +1,14 @@
+
+
+
+
+ [{oxmultilang ident="GENERAL_ADMIN_TITLE"}]
+
+
+
+
+
+
diff --git a/Application/views/admin/tpl/mailcheckmenu.tpl b/Application/views/admin/tpl/mailcheckmenu.tpl
new file mode 100644
index 0000000..4bf5304
--- /dev/null
+++ b/Application/views/admin/tpl/mailcheckmenu.tpl
@@ -0,0 +1,39 @@
+[{include file="headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign box="list"}]
+
+[{if $readonly}]
+ [{assign var="readonly" value="readonly disabled"}]
+[{else}]
+ [{assign var="readonly" value=""}]
+[{/if}]
+
+
+
+
+
+[{include file="pagetabsnippet.tpl"}]
+
+
+