From b07dab70549e9495be48d5fda078db9374fe2ae0 Mon Sep 17 00:00:00 2001 From: Derrick Heesbeen Date: Thu, 18 Jan 2018 22:02:37 +0100 Subject: [PATCH] [BUGFIX] di compile error fix, non excisting email/transport class --- Mail/Transport.php | 36 +++++++++++++++++-- .../experius_emailcatcher_index.xml | 4 +-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Mail/Transport.php b/Mail/Transport.php index 1d341f7..58b7628 100644 --- a/Mail/Transport.php +++ b/Mail/Transport.php @@ -13,11 +13,18 @@ namespace Experius\EmailCatcher\Mail; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Exception\MailException; use Magento\Framework\Mail\MessageInterface; +use Magento\Framework\Mail\TransportInterface; +use Magento\Store\Model\ScopeInterface; -class Transport extends \Magento\Email\Model\Transport +class Transport implements TransportInterface { + const XML_PATH_SENDING_SET_RETURN_PATH = 'system/smtp/set_return_path'; + + const XML_PATH_SENDING_RETURN_PATH_EMAIL = 'system/smtp/return_path_email'; + private $transport; private $message; @@ -35,8 +42,6 @@ public function __construct( $this->transport = $transport; $this->message = $message; $this->scopeConfig = $scopeConfig; - - parent::__construct($transport, $message, $scopeConfig); } public function setMessage(\Magento\Framework\Mail\Message $message) @@ -44,8 +49,33 @@ public function setMessage(\Magento\Framework\Mail\Message $message) $this->message = $message; } + public function sendMessage() + { + try { + + $isSetReturnPath = $this->scopeConfig->getValue( + self::XML_PATH_SENDING_SET_RETURN_PATH, + ScopeInterface::SCOPE_STORE + ); + $returnPathValue = $this->scopeConfig->getValue( + self::XML_PATH_SENDING_RETURN_PATH_EMAIL, + ScopeInterface::SCOPE_STORE + ); + + if ($isSetReturnPath == '1') { + $this->message->setReturnPath($this->message->getFrom()); + } elseif ($isSetReturnPath == '2' && $returnPathValue !== null) { + $this->message->setReturnPath($returnPathValue); + } + $this->transport->send($this->message); + } catch (\Exception $e) { + throw new MailException(__($e->getMessage()), $e); + } + } + public function getMessage() { return $this->message; } } + diff --git a/view/adminhtml/ui_component/experius_emailcatcher_index.xml b/view/adminhtml/ui_component/experius_emailcatcher_index.xml index fd33ff5..5b11ee8 100644 --- a/view/adminhtml/ui_component/experius_emailcatcher_index.xml +++ b/view/adminhtml/ui_component/experius_emailcatcher_index.xml @@ -45,7 +45,7 @@ - + @@ -64,7 +64,7 @@ - +