Commit e49966ea authored by jonas.goetze's avatar jonas.goetze

[TASK] Migrate to FluidEmail to be compatible with TYPO3 10 Mail API changes

parent 5d306c88
Pipeline #9614 failed with stages
in 3 minutes and 11 seconds
......@@ -17,9 +17,10 @@ namespace T3o\TerFe2\Service;
use T3o\TerFe2\Domain\Model\FrontendUser;
use T3o\TerFe2\Domain\Repository\FrontendUserRepository;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use Symfony\Component\Mime\Address;
use TYPO3\CMS\Core\Mail\FluidEmail;
use TYPO3\CMS\Core\Mail\Mailer;
class ExtkeyTransferMailService
{
......@@ -38,18 +39,18 @@ class ExtkeyTransferMailService
/** @var FrontendUser $user */
$user = $this->frontendUserRepository->findOneByUsername($username);
$mail = GeneralUtility::makeInstance(MailMessage::class);
$mail->setTo($user->getEmail(), $user->getName());
$mail->setSubject('Extension Key ' . $extkey . ' is transferred to you!');
$standalone = GeneralUtility::makeInstance(StandaloneView::class);
$standalone->setTemplatePathAndFilename('EXT:ter_fe2/Resources/Private/Templates/Mail/ExtensionKeyTransferMail.html');
$standalone->assignMultiple(
[
'name' => $user->getName(),
'extkey' => $extkey
]
);
$mail->setBody($standalone->render());
$mail->send();
$mail = GeneralUtility::makeInstance(FluidEmail::class);
$mail
->to(new Address($user->getEmail(), $user->getName()))
->subject('Extension Key ' . $extkey . ' is transferred to you!')
->format(FluidEmail::FORMAT_PLAIN)
->setTemplate('ExtensionKeyTransferMail')
->assignMultiple(
[
'name' => $user->getName(),
'extkey' => $extkey
]
);
GeneralUtility::makeInstance(Mailer::class)->send($mail);
}
}
\ No newline at end of file
......@@ -51,3 +51,6 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\T3o\TerFe2\Task
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['ter_fe2:extension'] = 'EXT:ter_fe2/Classes/Controller/Eid/ExtensionController.php';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['VersionMapper'] = \T3o\TerFe2\Routing\Aspect\VersionMapper::class;
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['templateRootPaths'][789] = 'EXT:ter_fe2/Resources/Private/Templates/Mail';
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['layoutRootPaths'][789] = 'EXT:ter_fe2/Resources/Private/Layouts';
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment