![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Cnc/Email/Preference/Mail/Rse/ |
<?php /** * Copyright (c) 2021 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved. * https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * Krzysztof Majkowski <[email protected]> */ namespace Cnc\Email\Preference\Mail\Rse; use Magento\Framework\App\Config\ScopeConfigInterface; use Mageplaza\Smtp\Helper\Data; use Zend\Log\Logger; use Zend\Log\Writer\Stream; use Zend\Mail\Message; use Zend\Mail\Transport\Smtp; use Zend\Mail\Transport\SmtpOptions; use Zend_Exception; use Zend_Mail_Transport_Smtp; class Mail extends \Mageplaza\Smtp\Mail\Rse\Mail { /** KDC MOFICIATION START */ /** * @var ScopeConfigInterface */ private $scopeConfig; /** * Mail constructor. * @param Data $helper * @param ScopeConfigInterface $scopeConfig */ public function __construct( Data $helper, ScopeConfigInterface $scopeConfig ) { parent::__construct($helper); $this->scopeConfig = $scopeConfig; } /** KDC MOFICIATION END */ /** * @overridden * @param $storeId * @return Smtp|Zend_Mail_Transport_Smtp * @throws Zend_Exception */ public function getTransport($storeId) { if ($this->_transport === null) { if (!isset($this->_smtpOptions[$storeId])) { $configData = $this->smtpHelper->getSmtpConfig('', $storeId); $options = [ 'host' => isset($configData['host']) ? $configData['host'] : '', 'port' => isset($configData['port']) ? $configData['port'] : '' ]; if (isset($configData['authentication']) && $configData['authentication'] !== "") { $options += [ 'auth' => $configData['authentication'], 'username' => isset($configData['username']) ? $configData['username'] : '', 'password' => $this->smtpHelper->getPassword($storeId) ]; } if (isset($configData['protocol']) && $configData['protocol'] !== "") { $options['ssl'] = $configData['protocol']; } $this->_smtpOptions[$storeId] = $options; } if (!isset($this->_smtpOptions[$storeId]['host']) || !$this->_smtpOptions[$storeId]['host']) { throw new Zend_Exception(__('A host is necessary for smtp transport, but none was given')); } if ($this->smtpHelper->versionCompare('2.2.8')) { $options = $this->_smtpOptions[$storeId]; if (isset($options['auth'])) { $options['connection_class'] = $options['auth']; $options['connection_config'] = [ 'username' => $options['username'], 'password' => $options['password'] ]; unset($options['auth'], $options['username'], $options['password']); } if (isset($options['ssl'])) { $options['connection_config']['ssl'] = $options['ssl']; unset($options['ssl']); } unset($options['type']); /** KDC MOFICIATION START */ $options['name'] = $this->scopeConfig->getValue('system/smtp/name'); /** KDC MOFICIATION END */ $options = new SmtpOptions($options); $this->_transport = new Smtp($options); } else { $this->_transport = new Zend_Mail_Transport_Smtp( $this->_smtpOptions[$storeId]['host'], $this->_smtpOptions[$storeId] ); } } return $this->_transport; } }