diff --git a/Classes/Utility/MailUtility.php b/Classes/Utility/MailUtility.php index 93bc423..9611e08 100644 --- a/Classes/Utility/MailUtility.php +++ b/Classes/Utility/MailUtility.php @@ -20,6 +20,7 @@ use TYPO3\CMS\Extbase\Service\ImageService; use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\View\TemplatePaths; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; +use Symfony\Component\Mime\Address; /** * @@ -219,8 +220,13 @@ class MailUtility } $textView->setTemplate($templateNameText); $mail = GeneralUtility::makeInstance(MailMessage::class); - $mail->setFrom($sender); - $mail->setSubject($subject); + if (version_compare(TYPO3_branch, '10.0', '>=')) { + $mail->from(new Address($sender)); + $mail->subject($subject); + } else { + $mail->setFrom($sender); + $mail->setSubject($subject); + } $bodydataText = []; $bodydataHtml = []; foreach ($data as $row) { @@ -320,11 +326,19 @@ class MailUtility $bodydataHtml[] = $htmlRow; break; case 'attachment': - $mail->attach(new \Swift_Attachment( - $row['data'][0], - $row['data'][1], - $row['data'][2] - )); + if (version_compare(TYPO3_branch, '10.0', '>=')) { + $mail->attach( + $row['data'][0], + $row['data'][1], + $row['data'][2] + ); + } else { + $mail->attach(new \Swift_Attachment( + $row['data'][0], + $row['data'][1], + $row['data'][2] + )); + } break; case 'attachmentBase64': $attachmentdata = explode(',', $row['data']); @@ -332,11 +346,19 @@ class MailUtility $mimetype = $matches[1]; preg_match('/\w*\/(.*);\w*/', $attachmentdata[0], $matches); $fileextension = $matches[1]; - $mail->attach(new \Swift_Attachment( - base64_decode($attachmentdata[1]), - 'attachment.' . $fileextension, - $mimetype - )); + if (version_compare(TYPO3_branch, '10.0', '>=')) { + $mail->attach( + base64_decode($attachmentdata[1]), + 'attachment.' . $fileextension, + $mimetype + ); + } else { + $mail->attach(new \Swift_Attachment( + base64_decode($attachmentdata[1]), + 'attachment.' . $fileextension, + $mimetype + )); + } break; } } @@ -380,16 +402,27 @@ class MailUtility ); foreach ($recipientsIntercecpted as $recipientIntercepted) { foreach ($recipients as $recipient) { - $mail->setSubject( - $subjectOrig . ' [ORIG-TO: ' . trim($recipient) . ']' - ); - $mail->setTo(trim($recipientIntercepted)); + if (version_compare(TYPO3_branch, '10.0', '>=')) { + $mail->subject( + $subjectOrig . ' [ORIG-TO: ' . trim($recipient) . ']' + ); + $mail->to(new Address(trim($recipientIntercepted))); + } else { + $mail->setSubject( + $subjectOrig . ' [ORIG-TO: ' . trim($recipient) . ']' + ); + $mail->setTo(trim($recipientIntercepted)); + } $mail->send(); } } } else { foreach ($recipients as $recipient) { - $mail->setTo(trim($recipient)); + if (version_compare(TYPO3_branch, '10.0', '>=')) { + $mail->to(new Address(trim($recipient))); + } else { + $mail->setTo(trim($recipient)); + } $mail->send(); } }