diff --git a/CHANGELOG.md b/CHANGELOG.md index 23b481c..1c2d293 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,69 @@ +## 4.0.0 (2023-10-25) + +[View Release](git@github.com:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/4.0.0) + +* [BUGFIX][IN23-251] Ported obsolete/deprecated install- and upgradeschema to db_schema.xml and db_schema_whitelist.json. *(Boris van Katwijk)* +* [FEATURE][IN23-252] Make EmailCatcher PHP 8.2 compatible; rework constructs and remove backwards compatibility for lower versions of Magento. *(Boris van Katwijk)* + + +## 3.5.3 (2023-08-23) + +[View Release](git@github.com:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.5.3) + +* [BUGFIX][#67][NEND-744] PHP Deprecated: Creation of dynamic property Experius\EmailCatcher\Cron\Clean::$connection is deprecated in /Cron/Clean.php on line 49 *(Boris van Katwijk)* + + +## 3.5.2 (2022-10-12) + +[View Release](git@github.com:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.5.2) + +* #63: ERROR - Run Cleanup *(Prashant Patel)* +* Update function imapUtf8 with check on string type *(Experius)* + + +## 3.5.1 (2022-07-21) + +[View Release](git@github.com:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.5.1) + +* [FEATURE][BACI-694] Changed adminhtml ui component to have dates in the grid based on timezone *(Quinn Stadens)* + + +## 3.5.0 (2021-02-19) + +[View Release](git@github.com:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.5.0) + +* [FEATURE] - Restored old setupscripts. Allows for reinstall on a new M2.2 environment *(Rens Wolters)* +* [FEATURE] - Added db_schema changes after removal of installscripts to installscripts *(Rens Wolters)* + + +## 3.4.4 (2020-11-25) + +[View Release](git@github.com:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.4.4) + +* [REFACTOR] - Fix backwards compatibility with 2.2.X *(Ruben Panis)* + + +## 3.4.3 (2020-11-25) + +[View Release](git@github.com:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.4.3) + +* [BUGFIX] - Add required parameter before optional parameter in constructor *(Ruben Panis)* + + +## 3.4.2 (2020-11-17) + +[View Release](git@github.com:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.4.2) + +* [BUGFIX] - Fixed recipient string in resend message *(Ruben Panis)* + + +## 3.4.1 (2020-10-27) + +[View Release](git@github.com:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.4.1) + +* [BUGFIX] fixed bug for email getting into spam cause of utf-8 *(martijnvanhaagen)* + + ## 3.4.0 (2020-10-22) [View Release](git@github.com:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.4.0) diff --git a/Controller/Adminhtml/Emailcatcher/Cleanup.php b/Controller/Adminhtml/EmailCatcher/Cleanup.php similarity index 79% rename from Controller/Adminhtml/Emailcatcher/Cleanup.php rename to Controller/Adminhtml/EmailCatcher/Cleanup.php index 243825f..19ad181 100644 --- a/Controller/Adminhtml/Emailcatcher/Cleanup.php +++ b/Controller/Adminhtml/EmailCatcher/Cleanup.php @@ -5,30 +5,23 @@ */ declare(strict_types=1); -namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher; +namespace Experius\EmailCatcher\Controller\Adminhtml\EmailCatcher; use Experius\EmailCatcher\Cron\Clean; +use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; -class Cleanup extends \Magento\Backend\App\Action +class Cleanup extends Action { /** - * @var Clean - */ - protected $clean; - - /** - * Cleanup constructor. - * * @param Context $context * @param Clean $clean */ public function __construct( Context $context, - Clean $clean + protected Clean $clean ) { parent::__construct($context); - $this->clean = $clean; } /** diff --git a/Controller/Adminhtml/Emailcatcher/Forward.php b/Controller/Adminhtml/EmailCatcher/Forward.php similarity index 76% rename from Controller/Adminhtml/Emailcatcher/Forward.php rename to Controller/Adminhtml/EmailCatcher/Forward.php index 60dce70..2f68119 100644 --- a/Controller/Adminhtml/Emailcatcher/Forward.php +++ b/Controller/Adminhtml/EmailCatcher/Forward.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher; +namespace Experius\EmailCatcher\Controller\Adminhtml\EmailCatcher; use Magento\Backend\App\Action\Context; use Magento\Framework\View\Result\PageFactory; @@ -13,21 +13,13 @@ class Forward extends \Magento\Backend\App\Action { /** - * @var PageFactory - */ - protected $resultPageFactory; - - /** - * Forward constructor. - * * @param Context $context * @param PageFactory $resultPageFactory */ public function __construct( Context $context, - PageFactory $resultPageFactory + protected PageFactory $resultPageFactory ) { - $this->resultPageFactory = $resultPageFactory; parent::__construct($context); } diff --git a/Controller/Adminhtml/Emailcatcher/Index.php b/Controller/Adminhtml/EmailCatcher/Index.php similarity index 68% rename from Controller/Adminhtml/Emailcatcher/Index.php rename to Controller/Adminhtml/EmailCatcher/Index.php index a401d22..3c47bbc 100644 --- a/Controller/Adminhtml/Emailcatcher/Index.php +++ b/Controller/Adminhtml/EmailCatcher/Index.php @@ -5,29 +5,22 @@ */ declare(strict_types=1); -namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher; +namespace Experius\EmailCatcher\Controller\Adminhtml\EmailCatcher; +use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; use Magento\Framework\View\Result\PageFactory; -class Index extends \Magento\Backend\App\Action +class Index extends Action { /** - * @var PageFactory - */ - protected $resultPageFactory; - - /** - * Index constructor. - * * @param Context $context * @param PageFactory $resultPageFactory */ public function __construct( Context $context, - PageFactory $resultPageFactory + protected PageFactory $resultPageFactory ) { - $this->resultPageFactory = $resultPageFactory; parent::__construct($context); } diff --git a/Controller/Adminhtml/Emailcatcher/Send.php b/Controller/Adminhtml/EmailCatcher/Send.php similarity index 78% rename from Controller/Adminhtml/Emailcatcher/Send.php rename to Controller/Adminhtml/EmailCatcher/Send.php index fa0de19..faa65c7 100644 --- a/Controller/Adminhtml/Emailcatcher/Send.php +++ b/Controller/Adminhtml/EmailCatcher/Send.php @@ -5,30 +5,23 @@ */ declare(strict_types=1); -namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher; +namespace Experius\EmailCatcher\Controller\Adminhtml\EmailCatcher; use Experius\EmailCatcher\Model\Mail; +use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; -class Send extends \Magento\Backend\App\Action +class Send extends Action { /** - * @var Mail - */ - protected $mail; - - /** - * Send constructor. - * * @param Context $context * @param Mail $mail */ public function __construct( Context $context, - Mail $mail + protected Mail $mail ) { parent::__construct($context); - $this->mail = $mail; } /** @@ -44,7 +37,7 @@ public function execute() $emailCatcherId = (isset($postData['emailcatcher_id'])) ? $postData['emailcatcher_id'] : false; if (!$emailCatcherId) { - $this->messageManager->addError('Oops, something went wrong'); + $this->messageManager->addErrorMessage('Oops, something went wrong'); return $resultRedirect->setPath('*/*/'); } diff --git a/Controller/Adminhtml/Preview/Index.php b/Controller/Adminhtml/Preview/Index.php index b119017..26bb902 100644 --- a/Controller/Adminhtml/Preview/Index.php +++ b/Controller/Adminhtml/Preview/Index.php @@ -8,37 +8,22 @@ namespace Experius\EmailCatcher\Controller\Adminhtml\Preview; use Experius\EmailCatcher\Model\EmailcatcherFactory; +use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; use Magento\Framework\Controller\Result\RawFactory; -class Index extends \Magento\Backend\App\Action +class Index extends Action { /** - * @var RawFactory - */ - protected $resultRawFactory; - - /** - * @var EmailcatcherFactory - */ - protected $emailCatcher; - - /** - * Index constructor. - * * @param Context $context * @param RawFactory $resultRawFactory * @param EmailcatcherFactory $emailCatcher */ public function __construct( Context $context, - RawFactory $resultRawFactory, - EmailcatcherFactory $emailCatcher + protected RawFactory $resultRawFactory, + protected EmailcatcherFactory $emailCatcher ) { - - $this->resultRawFactory = $resultRawFactory; - $this->emailCatcher = $emailCatcher; - parent::__construct($context); } diff --git a/Cron/Clean.php b/Cron/Clean.php index 6cad0db..33f6a7f 100644 --- a/Cron/Clean.php +++ b/Cron/Clean.php @@ -18,41 +18,21 @@ class Clean const CONFIG_DAYS_TO_CLEAN = 'emailcatcher/general/days_to_clean'; /** - * @var LoggerInterface - */ - protected $logger; - - /** - * @var ResourceConnection - */ - protected $resourceConnection; - - /** - * @var \Magento\Framework\DB\Adapter\AdapterInterface|null + * @var \Magento\Framework\DB\Adapter\AdapterInterface */ protected $connection; /** - * @var ScopeConfigInterface - */ - private $scopeConfig; - - /** - * Clean constructor. - * * @param LoggerInterface $logger * @param ResourceConnection $resourceConnection * @param ScopeConfigInterface $scopeConfig */ public function __construct( - LoggerInterface $logger, - ResourceConnection $resourceConnection, - ScopeConfigInterface $scopeConfig + protected LoggerInterface $logger, + protected ResourceConnection $resourceConnection, + protected ScopeConfigInterface $scopeConfig ) { - $this->logger = $logger; - $this->resourceConnection = $resourceConnection; $this->connection = $this->resourceConnection->getConnection(); - $this->scopeConfig = $scopeConfig; } /** @@ -60,11 +40,11 @@ public function __construct( * * @return int */ - public function getDaysToClean() + public function getDaysToClean(): int { $daysToCleanConfig = $this->scopeConfig->getValue(self::CONFIG_DAYS_TO_CLEAN, ScopeInterface::SCOPE_STORE); - - return (int)$daysToCleanConfig >= 0 ? $daysToCleanConfig : self::DEFAULT_DAYS_TO_CLEAN; + + return (int)$daysToCleanConfig >= 0 ? (int)$daysToCleanConfig : self::DEFAULT_DAYS_TO_CLEAN; } /** @@ -72,7 +52,7 @@ public function getDaysToClean() * * @return int $deletionCount */ - public function execute() + public function execute(): int { $where = "created_at < '" . date('c', time() - ($this->getDaysToClean() * (3600 * 24))) . "'"; @@ -83,6 +63,6 @@ public function execute() $this->logger->info(__('Experius EmailCatcher Cleanup: Removed %1 records', $deletionCount)); - return (int)$deletionCount; + return $deletionCount; } } diff --git a/Model/Emailcatcher.php b/Model/Emailcatcher.php index 66400d9..9c1d1df 100644 --- a/Model/Emailcatcher.php +++ b/Model/Emailcatcher.php @@ -7,14 +7,14 @@ namespace Experius\EmailCatcher\Model; -use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Data\Collection\AbstractDb; +use Magento\Framework\Model\AbstractModel; use Magento\Framework\Model\Context; use Magento\Framework\Model\ResourceModel\AbstractResource; use Magento\Framework\Registry; use Experius\EmailCatcher\Registry\CurrentTemplate; -class Emailcatcher extends \Magento\Framework\Model\AbstractModel +class Emailcatcher extends AbstractModel { /** * @var string @@ -27,38 +27,22 @@ class Emailcatcher extends \Magento\Framework\Model\AbstractModel protected $_eventObject = 'email'; /** - * @var ProductMetadataInterface|null - */ - protected $magentoProductMetaData; - /** - * @var CurrentTemplate - */ - private $currentTemplate; - - /** - * Emailcatcher constructor. - * * @param Context $context * @param Registry $registry - * @param ProductMetadataInterface $magentoProductMetaData + * @param CurrentTemplate $currentTemplate * @param AbstractResource|null $resource * @param AbstractDb|null $resourceCollection - * @param CurrentTemplate $currentTemplate * @param array $data */ public function __construct( Context $context, Registry $registry, - CurrentTemplate $currentTemplate, - ProductMetadataInterface $magentoProductMetaData = null, + protected CurrentTemplate $currentTemplate, AbstractResource $resource = null, AbstractDb $resourceCollection = null, array $data = [] ) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); - $this->currentTemplate = $currentTemplate; - $this->magentoProductMetaData = $magentoProductMetaData ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(ProductMetadataInterface::class); } /** @@ -79,12 +63,10 @@ public function saveMessage($message) $bodyObject = $message->getBody(); if (!method_exists($bodyObject, 'getRawContent') && method_exists($message, 'getRawMessage')) { - $zendMessageObject = new \Zend\Mail\Message(); + $zendMessageObject = new \Laminas\Mail\Message(); $zendMessage = $zendMessageObject::fromString($message->getRawMessage()); $body = $zendMessage->getBodyText(); - if (version_compare($this->magentoProductMetaData->getVersion(), "2.3.3", ">=")) { - $body = quoted_printable_decode($body); - } + $body = quoted_printable_decode($body); $recipient = $this->getEmailAddressesFromObject($zendMessage->getTo()); $sender = $this->getEmailAddressesFromObject($zendMessage->getFrom()); } elseif (method_exists($bodyObject, 'getRawContent')) { @@ -130,15 +112,12 @@ public function getEmailAddressesFromObject($addresses, $asString = true) } /** - * @todo imap_utf8 replacement * @param string $string * @return string $string + * @todo imap_utf8 replacement */ public function imapUtf8($string) { - if (function_exists('imap_utf8') && is_string($string)) { - $string = imap_utf8($string); - } - return $string; + return (function_exists('imap_utf8') && is_string($string)) ? imap_utf8($string) : $string; } } diff --git a/Model/Mail.php b/Model/Mail.php index 5f6ac6b..f4ccbaa 100644 --- a/Model/Mail.php +++ b/Model/Mail.php @@ -7,110 +7,40 @@ namespace Experius\EmailCatcher\Model; -use Magento\Framework\App\ProductMetadataInterface; -use Magento\Framework\Mail\Message; -use Magento\Framework\Mail\TransportInterfaceFactory; +use Magento\Framework\Mail\AddressConverter; +use Magento\Framework\Mail\EmailMessageInterfaceFactory; +use Magento\Framework\Mail\MimeMessageInterfaceFactory; +use Magento\Framework\Mail\MimePartInterfaceFactory; use Experius\EmailCatcher\Registry\CurrentTemplate; +use Magento\Framework\Mail\TransportInterfaceFactory; class Mail { - /** - * @var Message - */ - protected $messageFactory; - - /** - * @var EmailcatcherFactory - */ - protected $emailCatcherFactory; - - /** - * @var TransportInterfaceFactory - */ - protected $mailTransportFactory; - - /** - * @var ProductMetadataInterface - */ - protected $magentoProductMetaData; - - /** - * @var \Magento\Framework\Mail\EmailMessageInterfaceFactory|null - */ - protected $emailMessageInterfaceFactory; - - /** - * @var \Magento\Framework\Mail\MimeMessageInterfaceFactory|null - */ - protected $mimeMessageInterfaceFactory; - - /** - * @var \Magento\Framework\Mail\MimePartInterfaceFactory|null - */ - protected $mimePartInterfaceFactory; - - /** - * @var \Magento\Framework\Mail\AddressConverter|null - */ - protected $addressConverter; - /** * Param that used for storing all message data until it will be used * * @var array */ private $messageData = []; - /** - * @var CurrentTemplate - */ - private $currentTemplate; /** - * Mail constructor. - * - * @param Message $messageFactory - * @param EmailcatcherFactory $emailcatcherFactory - * @param TransportInterfaceFactory $transportInterfaceFactory + * @param EmailcatcherFactory $emailCatcherFactory * @param CurrentTemplate $currentTemplate - * @param ProductMetadataInterface|null $magentoProductMetaData - * @param \Magento\Framework\Mail\EmailMessageInterfaceFactory|null $emailMessageInterfaceFactory - * @param \Magento\Framework\Mail\MimeMessageInterfaceFactory|null $mimeMessageInterfaceFactory - * @param \Magento\Framework\Mail\MimePartInterfaceFactory|null $mimePartInterfaceFactory - * @param \Magento\Framework\Mail\AddressConverter|null $addressConverter + * @param EmailMessageInterfaceFactory $emailMessageInterfaceFactory + * @param AddressConverter $addressConverter + * @param MimePartInterfaceFactory $mimePartInterfaceFactory + * @param MimeMessageInterfaceFactory $mimeMessageInterfaceFactory + * @param TransportInterfaceFactory $transportFactory */ public function __construct( - Message $messageFactory, - EmailcatcherFactory $emailcatcherFactory, - TransportInterfaceFactory $transportInterfaceFactory, - CurrentTemplate $currentTemplate, - ProductMetadataInterface $magentoProductMetaData = null, - $emailMessageInterfaceFactory = null, - $mimeMessageInterfaceFactory = null, - $mimePartInterfaceFactory = null, - $addressConverter = null + protected EmailcatcherFactory $emailCatcherFactory, + protected CurrentTemplate $currentTemplate, + protected EmailMessageInterfaceFactory $emailMessageInterfaceFactory, + protected AddressConverter $addressConverter, + protected MimePartInterfaceFactory $mimePartInterfaceFactory, + protected MimeMessageInterfaceFactory $mimeMessageInterfaceFactory, + protected TransportInterfaceFactory $transportFactory ) { - $this->messageFactory = $messageFactory; - $this->emailCatcherFactory = $emailcatcherFactory; - $this->mailTransportFactory = $transportInterfaceFactory; - $this->currentTemplate = $currentTemplate; - - $this->magentoProductMetaData = $magentoProductMetaData ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(ProductMetadataInterface::class); - - if (version_compare($this->magentoProductMetaData->getVersion(), "2.3.3", ">=")) { - $this->emailMessageInterfaceFactory = $emailMessageInterfaceFactory - ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Mail\EmailMessageInterfaceFactory::class); - $this->mimeMessageInterfaceFactory = $mimeMessageInterfaceFactory - ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Mail\MimeMessageInterfaceFactory::class); - $this->mimePartInterfaceFactory = $mimePartInterfaceFactory - ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Mail\MimePartInterfaceFactory::class); - $this->addressConverter = $addressConverter - ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Mail\AddressConverter::class); - } } /** @@ -127,36 +57,26 @@ public function sendMessage($emailCatcherId, $alternativeToAddress) if ($templateIdentifier) { $this->currentTemplate->set($templateIdentifier); } - $recipient = ($alternativeToAddress) ? $alternativeToAddress : $emailCatcher->getRecipient(); - - if (version_compare($this->magentoProductMetaData->getVersion(), "2.3.3", ">=")) { - // default message type is MimeInterface::TYPE_HTML, so no need to set it - $this->messageData['from'][] = $this->addressConverter->convert( - mb_decode_mimeheader($emailCatcher->getSender()), - mb_decode_mimeheader($emailCatcher->getSender()) - ); - $this->messageData['to'][] = $this->addressConverter->convert(mb_decode_mimeheader($recipient), mb_decode_mimeheader($recipient)); - $content = $emailCatcher->getBody(); - $mimePart = $this->mimePartInterfaceFactory->create(['content' => $content]); - $this->messageData['body'] = $this->mimeMessageInterfaceFactory->create( - ['parts' => [$mimePart]] - ); - $this->messageData['subject'] = html_entity_decode( - (string)$emailCatcher->getSubject(), - ENT_QUOTES - ); - $message = $this->emailMessageInterfaceFactory->create($this->messageData); - } else { - /** @var Message $message */ - $message = $this->messageFactory; - $message->setMessageType('html'); - $message->setFrom(mb_encode_mimeheader($emailCatcher->getSender())); - $message->addTo(mb_encode_mimeheader($recipient)); - $message->setBodyHtml($emailCatcher->getBody()); - $message->setSubject(mb_encode_mimeheader($emailCatcher->getSubject())); - } - - $mailTransport = $this->mailTransportFactory->create(['message' => clone $message]); + $recipient = $alternativeToAddress ?: $emailCatcher->getRecipient(); + + // default message type is MimeInterface::TYPE_HTML, so no need to set it + $this->messageData['from'][] = $this->addressConverter->convert( + mb_decode_mimeheader($emailCatcher->getSender()), + mb_decode_mimeheader($emailCatcher->getSender()) + ); + $this->messageData['to'][] = $this->addressConverter->convert(mb_decode_mimeheader($recipient), mb_decode_mimeheader($recipient)); + $content = $emailCatcher->getBody(); + $mimePart = $this->mimePartInterfaceFactory->create(['content' => $content]); + $this->messageData['body'] = $this->mimeMessageInterfaceFactory->create( + ['parts' => [$mimePart]] + ); + $this->messageData['subject'] = html_entity_decode( + (string)$emailCatcher->getSubject(), + ENT_QUOTES + ); + $message = $this->emailMessageInterfaceFactory->create($this->messageData); + + $mailTransport = $this->transportFactory->create(['message' => clone $message]); $mailTransport->sendMessage(); } } diff --git a/Model/ResourceModel/Emailcatcher/Grid/Collection.php b/Model/ResourceModel/Emailcatcher/Grid/Collection.php index 4287bc4..9fd9b83 100644 --- a/Model/ResourceModel/Emailcatcher/Grid/Collection.php +++ b/Model/ResourceModel/Emailcatcher/Grid/Collection.php @@ -16,12 +16,7 @@ class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult { /** - * Collection constructor. - * - * @param EntityFactory $entityFactory - * @param Logger $logger - * @param FetchStrategy $fetchStrategy - * @param EventManager $eventManager + * @inheritDoc */ public function __construct( EntityFactory $entityFactory, diff --git a/Plugin/Magento/Framework/Mail/Template/TransportBuilder.php b/Plugin/Magento/Framework/Mail/Template/TransportBuilder.php index 719e0bb..7e2ae14 100644 --- a/Plugin/Magento/Framework/Mail/Template/TransportBuilder.php +++ b/Plugin/Magento/Framework/Mail/Template/TransportBuilder.php @@ -7,22 +7,16 @@ namespace Experius\EmailCatcher\Plugin\Magento\Framework\Mail\Template; +use Experius\EmailCatcher\Registry\CurrentTemplate; + class TransportBuilder { - - /** - * @var \Experius\EmailCatcher\Registry\CurrentTemplate - */ - private $currentTemplate; - /** - * TransportBuilder constructor. - * @param \Experius\EmailCatcher\Registry\CurrentTemplate $currentTemplate + * @param CurrentTemplate $currentTemplate */ public function __construct( - \Experius\EmailCatcher\Registry\CurrentTemplate $currentTemplate + private CurrentTemplate $currentTemplate ) { - $this->currentTemplate = $currentTemplate; } /** diff --git a/Plugin/Magento/Framework/Mail/TransportInterface.php b/Plugin/Magento/Framework/Mail/TransportInterface.php index 0286e80..bac135c 100644 --- a/Plugin/Magento/Framework/Mail/TransportInterface.php +++ b/Plugin/Magento/Framework/Mail/TransportInterface.php @@ -19,34 +19,15 @@ class TransportInterface const CONFIG_PATH_TEMPLATE_WHITELIST = 'emailcatcher/whitelist/email_templates'; /** - * @var ScopeConfigInterface - */ - private $scopeConfig; - - /** - * @var EmailcatcherFactory - */ - private $emailCatcher; - /** - * @var CurrentTemplate - */ - private $currentTemplate; - - /** - * TransportInterface constructor. - * * @param ScopeConfigInterface $scopeConfig * @param EmailcatcherFactory $emailCatcher * @param CurrentTemplate $currentTemplate */ public function __construct( - ScopeConfigInterface $scopeConfig, - EmailcatcherFactory $emailCatcher, - CurrentTemplate $currentTemplate + private ScopeConfigInterface $scopeConfig, + private EmailcatcherFactory $emailCatcher, + private CurrentTemplate $currentTemplate ) { - $this->scopeConfig = $scopeConfig; - $this->emailCatcher = $emailCatcher; - $this->currentTemplate = $currentTemplate; } /** @@ -54,7 +35,8 @@ public function __construct( * * @param \Magento\Framework\Mail\TransportInterface $subject * @param \Closure $proceed - * @return \Closure $proceed|void + * @return \Closure|void $proceed + * @throws \ReflectionException */ public function aroundSendMessage( \Magento\Framework\Mail\TransportInterface $subject, diff --git a/README.md b/README.md index aa59c45..257a293 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,20 @@ - [Installation](#markdown-header-installation) - [Versions](#markdown-header-versions) - [Enable email catcher](#markdown-header-enable-email-catcher) - - [Change log](#markdown-header-change-log) ## Main Functionalities - Log all Emails send by Magento - - View email contecnt in popup (Nice for testing and styling) - - Forward a catched email - - Resend a catched email - - Cleanup of emails older then 30 days (cron or manual) + - View email content in popup (Nice for testing and styling) + - Forward a caught email + - Resend a caught email + - Cleanup emails older than 30 days (cron or manual) - Send emails based on whitelisted email templates ## Versions -- Version 3.0.0 or higher is fully compatible with 2.2.x and 2.3.x + +- Version 4.x or higher is compatible with Magento >= 2.4.6-p2; PHP >= 8.2 + +- Version 3.x is compatible with Magento >= 2.2.0 <= 2.4.5; PHP 7.4 compatible [**Please note that from 3.0.0 onward the composer require changed to experius/module-emailcatcher**] @@ -29,17 +31,15 @@ In production please use the `--keep-generated` option ### Type 1: Zip file - - Unzip the zip file in `app/code/Experius` + - Unzip the zip file in `app/code/Experius/EmailCatcher` - Enable the module by running `php bin/magento module:enable Experius_EmailCatcher` - Apply database updates by running `php bin/magento setup:upgrade` - Flush the cache by running `php bin/magento cache:flush` ### Type 2: Composer - Make the module available in a composer repository for example: - - private repository `repo.magento.com` - public repository `packagist.org` - public github repository as vcs - - Add the composer repository to the configuration by running `composer config repositories.repo.magento.com composer https://repo.magento.com/` - Install the module composer by running `composer require experius/module-emailcatcher` - Enable the module by running `php bin/magento module:enable Experius_EmailCatcher` - Apply database updates by running `php bin/magento setup:upgrade` @@ -58,20 +58,3 @@ Utilise whitelist functionality Admin grid - System > Tools > Email Catcher - -## Change log -Version 3.1.0 - November 8th, 2019 - - - [FEATURE] Created preferences on Magento email classes (Transport / TransportBuilder) to preserve template identifier on email transport. This will allow filtering of email sending (in sendMessage()) based of configurable template whitelist. - - [FEATURE] Added logic to check email versus whitelisted templates and send those configured to be whitelisted - - [FEATURE] Added custom email templates to dropdown selector for templates to whitelist - - [FEATURE] Added logic to check email versus whitelist, where non-whitelisted templates are halted. - - [BUGFIX] Empty whitelist was still sending email, resolved this by making !empty() check on template whitelist. - - [REFACTOR] Small refactor for readability of class functions in plugin. - - [BUGFIX] Message for resending was incorrectly displaying empty email adress. Message rewritten to "email was resent". - -Version 3.0.0 - October 9th, 2019 - - - [REFACTOR] DocBlocks and module composer require namespace changed - - [FEATURE] Magento 2.3.3 support for forwarding and resending emails using the newly introduced \Magento\Framework\Mail\EmailMessageInterface. Fully backwards compatible to 2.2.x - - [DOCS] Updated README, starting change logs diff --git a/Registry/CurrentTemplate.php b/Registry/CurrentTemplate.php index 88ad263..91ec278 100644 --- a/Registry/CurrentTemplate.php +++ b/Registry/CurrentTemplate.php @@ -7,19 +7,26 @@ namespace Experius\EmailCatcher\Registry; -/** - * Class CurrentTemplate - * @package Experius\EmailCatcher\Registry - */ class CurrentTemplate { private $templateIdentifier; + /** + * Set template identifier + * + * @param $templateIdentifier + * @return void + */ public function set($templateIdentifier) { $this->templateIdentifier = $templateIdentifier; } + /** + * Get template identifier + * + * @return mixed + */ public function get() { return $this->templateIdentifier; diff --git a/composer.json b/composer.json index fe0946d..60390a8 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ }, { "name": "Boris van Katwijk", - "email": "boris@experius.nl" + "email": "borisvankatwijk@happyhorizon.com" }, { "name": "Lewis Vonken", diff --git a/etc/module.xml b/etc/module.xml index 99fd838..cb01919 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,7 +1,8 @@ - + + diff --git a/view/adminhtml/web/js/grid/columns/actions.js b/view/adminhtml/web/js/grid/columns/actions.js index e5a3262..11a77c3 100644 --- a/view/adminhtml/web/js/grid/columns/actions.js +++ b/view/adminhtml/web/js/grid/columns/actions.js @@ -1,11 +1,6 @@ /** - * A Magento 2 module named Experius/EmailCatcher - * Copyright (C) 2019 Experius - * - * This file included in Experius/EmailCatcher is licensed under OSL 3.0 - * - * http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * Please see LICENSE.txt for the full text of the OSL 3.0 license + * Copyright © Experius B.V. All rights reserved. + * See COPYING.txt for license details. */ define([ 'underscore',