From 1097aa0efb2c8168c8b10b790d2db89f7574d8a1 Mon Sep 17 00:00:00 2001 From: karsten Date: Wed, 17 Jun 2020 11:10:57 +0200 Subject: [PATCH 1/6] [BUGFIX] Call swift encoder only < TYPO3 10 --- Classes/Dmailer.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Classes/Dmailer.php b/Classes/Dmailer.php index 64455ed1b..3026918a2 100755 --- a/Classes/Dmailer.php +++ b/Classes/Dmailer.php @@ -130,9 +130,9 @@ class Dmailer implements LoggerAwareInterface * @var MarkerBasedTemplateService */ protected $templateService; - + protected $message = ''; - + protected $notificationJob = false; protected function getCharsetConverter() @@ -679,7 +679,7 @@ public function dmailer_setBeginEnd(int $mid, string $key) $mail->setTo($this->from_email, $from_name); $mail->setFrom($this->from_email, $from_name); $mail->setSubject($subject); - + if ($this->replyto_email !== '') { $mail->setReplyTo($this->replyto_email); } @@ -1048,12 +1048,13 @@ public function sendTheMail($recipient, $recipRow = null) // TODO: setContent should set the images (includeMedia) or add attachment $this->setContent($mailer); - if ($this->encoding == 'base64') { - $mailer->setEncoder(\Swift_Encoding::getBase64Encoding()); - } - - if ($this->encoding == '8bit') { - $mailer->setEncoder(\Swift_Encoding::get8BitEncoding()); + if ($versionInformation->getMajorVersion() < 10) { + if ($this->encoding == 'base64') { + $mailer->setEncoder(\Swift_Encoding::getBase64Encoding()); + } + if ($this->encoding == '8bit') { + $mailer->setEncoder(\Swift_Encoding::get8BitEncoding()); + } } $mailer->send(); From fbc350e93470fcbf5f34c36fa66d33fe292eb024 Mon Sep 17 00:00:00 2001 From: karsten Date: Wed, 17 Jun 2020 11:12:56 +0200 Subject: [PATCH 2/6] [BUGFIX] Add missing request on getPageAndRootlineWithDomain --- Classes/DirectMailUtility.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Classes/DirectMailUtility.php b/Classes/DirectMailUtility.php index d7047c9ee..13c2de89b 100644 --- a/Classes/DirectMailUtility.php +++ b/Classes/DirectMailUtility.php @@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Error\Http\ServiceUnavailableException; use TYPO3\CMS\Core\Exception\SiteNotFoundException; use TYPO3\CMS\Core\Http\ImmediateResponseException; +use TYPO3\CMS\Core\Http\ServerRequestFactory; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Messaging\FlashMessage; @@ -1523,7 +1524,7 @@ public static function initializeTsfe(int $pageId, int $language = 0, bool $useC } else { $GLOBALS['TSFE'] = GeneralUtility::makeInstance(TypoScriptFrontendController::class, $GLOBALS['TYPO3_CONF_VARS'], $pageId, 0); } - + // for certain situations we need to trick TSFE into granting us // access to the page in any case to make getPageAndRootline() work @@ -1533,8 +1534,13 @@ public static function initializeTsfe(int $pageId, int $language = 0, bool $useC $GLOBALS['TSFE']->gr_list = $pageRecord['fe_group']; $GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance(PageRepository::class); - $GLOBALS['TSFE']->getPageAndRootlineWithDomain($pageId); + if ($versionInformation->getMajorVersion() === 10) { + $request = $GLOBALS['TYPO3_REQUEST'] ?? ServerRequestFactory::fromGlobals(); + $GLOBALS['TSFE']->getPageAndRootlineWithDomain($pageId, $request); + } else { + $GLOBALS['TSFE']->getPageAndRootlineWithDomain($pageId); + } // restore gr_list $GLOBALS['TSFE']->gr_list = $groupListBackup; From 6e81ca4a0dae47695e58a7971ede82c3095f7e73 Mon Sep 17 00:00:00 2001 From: karsten Date: Wed, 17 Jun 2020 11:09:32 +0200 Subject: [PATCH 3/6] [BUGFIX] Refactore preparing the mailer for sending mails New symfony mailer is used by TYPO3 10. Restructure code to reduce version check call. --- Classes/Dmailer.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Classes/Dmailer.php b/Classes/Dmailer.php index 3026918a2..5b70d5312 100755 --- a/Classes/Dmailer.php +++ b/Classes/Dmailer.php @@ -990,21 +990,30 @@ public function setContent(&$mailer) */ public function sendTheMail($recipient, $recipRow = null) { + if ($this->replyto_email) { + $replyTo = ['mail'=> $this->replyto_email, 'name' => $this->replyto_name]; + } else { + $replyTo = ['mail'=> $this->from_email, 'name' => $this->from_name]; + } /** @var MailMessage $mailer */ $mailer = GeneralUtility::makeInstance(MailMessage::class); - $mailer->setFrom(array($this->from_email => $this->from_name)); - $mailer->setSubject($this->subject); + + $versionInformation = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Information\Typo3Version::class); if ($versionInformation->getMajorVersion() === 10) { + $mailer->from(new Address($this->from_email, $this->from_name)); + $mailer->subject($this->subject); $mailer->priority($this->priority); + $mailer->replyTo(new Address($replyTo['mail'], $replyTo['name'])); + // set the recipient + $mailer->to(new Address($recipient->getAddress(), $recipient->getName())); } else { + $mailer->setFrom(array($this->from_email => $this->from_name)); + $mailer->setSubject($this->subject); $mailer->setPriority($this->priority); - } - - if ($this->replyto_email) { - $mailer->setReplyTo(array($this->replyto_email => $this->replyto_name)); - } else { - $mailer->setReplyTo(array($this->from_email => $this->from_name)); + $mailer->setReplyTo(array($replyTo['mail'] => $replyTo['name'])); + // set the recipient + $mailer->setTo($recipient); } // setting additional header @@ -1037,13 +1046,6 @@ public function sendTheMail($recipient, $recipRow = null) $mailer->setReturnPath($this->dmailer['sys_dmail_rec']['return_path']); } - // set the recipient - $versionInformation = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Information\Typo3Version::class); - if ($versionInformation->getMajorVersion() === 10) { - $mailer->to($recipient); - } else { - $mailer->setTo($recipient); - } // TODO: setContent should set the images (includeMedia) or add attachment $this->setContent($mailer); From 5d725eee505921f06190c665a395e7f03391cd9a Mon Sep 17 00:00:00 2001 From: karsten Date: Wed, 17 Jun 2020 11:13:31 +0200 Subject: [PATCH 4/6] [TASK] Extend dependency to TYPO3 v10 --- ext_emconf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext_emconf.php b/ext_emconf.php index 99557f078..9041ce81b 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -36,7 +36,7 @@ 'depends' => [ 'tt_address' => '', 'php' => '7.2.0', - 'typo3' => '9.5.0-9.5.99', + 'typo3' => '9.5.0-10.4.99', 'rdct' => '1.0.0', ], 'conflicts' => [ From f4728ac43f99537c290318d585af8b6faa37cf69 Mon Sep 17 00:00:00 2001 From: karsten Date: Wed, 17 Jun 2020 11:15:13 +0200 Subject: [PATCH 5/6] [TASK] Change back the package name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 731c05c2a..bf572c729 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "azich/direct-mail", + "name": "directmailteam/direct-mail", "type": "typo3-cms-extension", "description": "Advanced Direct Mail/Newsletter mailer system with sophisticated options for personalization of emails including response statistics. Fork of kartolo/direct-mail.", "keywords": [ From 9219fc17d4fa98f416b309afcbdf86cf68b0d373 Mon Sep 17 00:00:00 2001 From: karsten Date: Wed, 17 Jun 2020 11:17:39 +0200 Subject: [PATCH 6/6] [TASK] Set dependency on rdct to 2.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bf572c729..f850336b9 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "typo3/cms-core": "^10.3", "friendsoftypo3/jumpurl": "^8.0", "friendsoftypo3/tt-address": "^4.3 || ^5.0", - "friendsoftypo3/rdct": "dev-master" + "friendsoftypo3/rdct": "^2.0" }, "require-dev": { "roave/security-advisories": "dev-master"