show communication protocol from shop

# Conflicts:
#	views/twig/admin/mailConfigCheck.html.twig
Cette révision appartient à :
2024-07-09 23:33:17 +02:00
Parent 2af6727797
révision 37839b269c
4 fichiers modifiés avec 35 ajouts et 3 suppressions

Voir le fichier

@ -33,6 +33,7 @@ class MailConfigCheck extends AdminDetailsController
{
$this->checkDataAreSet();
$this->addTplParam('shop', Registry::getConfig()->getActiveShop());
$this->addTplParam('recipient', $this->testMailAddress);
return parent::render();
}
@ -74,13 +75,31 @@ class MailConfigCheck extends AdminDetailsController
{
try {
$shop = Registry::getConfig()->getActiveShop();
$config = Registry::getConfig();
$mail = oxNew(Email::class);
$mail->setRecipient($this->testMailAddress);
$mail->setRecipient(
trim(Registry::getRequest()->getRequestEscapedParameter('recipient')) ?: $this->testMailAddress
);
$mail->setBody('.');
$mail->setFrom($shop->getFieldData('oxowneremail'));
$currentDebug = $config->getConfigParam('iDebug');
$config->setConfigParam('iDebug', 6);
$mail->setSmtp();
ob_start();
$mail->send();
$communication = ob_get_contents();
ob_end_clean();
$re = '/(^|\<br\>)(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s)/m';
$subst = "$1";
$communication = preg_replace($re, $subst, $communication);
$config->setConfigParam('iDebug', $currentDebug);
$this->addTplParam('mailer', $mail->getMailer());
$this->addTplParam('communication', $communication);
} catch (Exception $e) {
Registry::getUtilsView()->addErrorToDisplay($e);
}