* @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 "