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; diff --git a/Classes/Dmailer.php b/Classes/Dmailer.php index 64455ed1b..5b70d5312 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); } @@ -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,23 +1046,17 @@ 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); - 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(); diff --git a/composer.json b/composer.json index 731c05c2a..f850336b9 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": [ @@ -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" 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' => [