diff --git a/typo3/sysext/backend/Classes/Security/EmailLoginNotification.php b/typo3/sysext/backend/Classes/Security/EmailLoginNotification.php index 8f3f77a3c9aef11f062bdc7d2ff01f81fad6db9e..440a1d573eaccc236639eed7265cbf787bcb5566 100644 --- a/typo3/sysext/backend/Classes/Security/EmailLoginNotification.php +++ b/typo3/sysext/backend/Classes/Security/EmailLoginNotification.php @@ -93,15 +93,18 @@ class EmailLoginNotification */ protected function sendEmail(string $recipient, AbstractUserAuthentication $user, string $subjectPrefix = null): void { - $subject = $subjectPrefix . ' New TYPO3 Login at "' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '" from ' . GeneralUtility::getIndpEnv('REMOTE_ADDR'); $headline = 'TYPO3 Backend Login notification'; $recipients = explode(',', $recipient); $email = GeneralUtility::makeInstance(FluidEmail::class) ->to(...$recipients) - ->subject($subject) ->setRequest($this->request) ->setTemplate('Security/LoginNotification') - ->assignMultiple(['user' => $user->user, 'headline' => $headline]); + ->assignMultiple([ + 'user' => $user->user, + 'prefix' => $subjectPrefix, + 'language' => $user->uc['lang'] ?? 'default', + 'headline' => $headline + ]); GeneralUtility::makeInstance(Mailer::class)->send($email); } } diff --git a/typo3/sysext/backend/Resources/Private/Templates/Email/Security/LoginNotification.html b/typo3/sysext/backend/Resources/Private/Templates/Email/Security/LoginNotification.html index 7e0db4d42a555d56bea2b48619db770e1b420b17..36e8c2d1eb99cbc19bf7f75d8fc27b587aa009f8 100644 --- a/typo3/sysext/backend/Resources/Private/Templates/Email/Security/LoginNotification.html +++ b/typo3/sysext/backend/Resources/Private/Templates/Email/Security/LoginNotification.html @@ -1,4 +1,5 @@ <f:layout name="SystemEmail" /> +<f:section name="Subject">{prefix} New Login at "{typo3.sitename}"</f:section> <f:section name="Title">{headline}</f:section> <f:section name="Main"> <h4>{introduction}</h4> diff --git a/typo3/sysext/backend/Resources/Private/Templates/Email/Security/LoginNotification.txt b/typo3/sysext/backend/Resources/Private/Templates/Email/Security/LoginNotification.txt index 2f991f4e65b4fdbaf3e7fc841f3bd08bc3e226d2..0041e8a1e3fd98725ab9ef4e9a19dd3ebf431b7a 100644 --- a/typo3/sysext/backend/Resources/Private/Templates/Email/Security/LoginNotification.txt +++ b/typo3/sysext/backend/Resources/Private/Templates/Email/Security/LoginNotification.txt @@ -1,4 +1,5 @@ <f:layout name="SystemEmail" /> +<f:section name="Subject">{prefix} New Login at "{typo3.sitename}"</f:section> <f:section name="Title">{headline}</f:section> <f:section name="Main">{introduction} The user "{user.username}" logged in from the IP address "{normalizedParams.remoteAddress}" at the site "{typo3.sitename}". diff --git a/typo3/sysext/backend/Tests/Unit/Security/EmailLoginNotificationTest.php b/typo3/sysext/backend/Tests/Unit/Security/EmailLoginNotificationTest.php index bf898e899b42aeba319d8a1aafadadba706e442b..ba24b6e7a6b66ab0d97a1a875e632e749cd70995 100644 --- a/typo3/sysext/backend/Tests/Unit/Security/EmailLoginNotificationTest.php +++ b/typo3/sysext/backend/Tests/Unit/Security/EmailLoginNotificationTest.php @@ -128,7 +128,6 @@ class EmailLoginNotificationTest extends UnitTestCase $subject->emailAtLogin(['user' => $userData], $backendUser); $mailMessage->to('typo3-admin@acme.com')->shouldHaveBeenCalled(); - $mailMessage->subject('[AdminLoginWarning] New TYPO3 Login at "My TYPO3 Inc." from 127.0.0.1')->shouldHaveBeenCalled(); } /** @@ -158,7 +157,6 @@ class EmailLoginNotificationTest extends UnitTestCase $subject = new EmailLoginNotification(); $subject->emailAtLogin(['user' => $userData], $backendUser); - $mailMessage->subject('[AdminLoginWarning] New TYPO3 Login at "My TYPO3 Inc." from 127.0.0.1')->shouldHaveBeenCalled(); $mailMessage->to('typo3-admin@acme.com')->shouldHaveBeenCalled(); } @@ -190,7 +188,6 @@ class EmailLoginNotificationTest extends UnitTestCase $subject->emailAtLogin(['user' => $userData], $backendUser); $mailMessage->to('typo3-admin@acme.com')->shouldHaveBeenCalled(); - $mailMessage->subject('[LoginWarning] New TYPO3 Login at "My TYPO3 Inc." from 127.0.0.1')->shouldHaveBeenCalled(); } /** @@ -224,7 +221,6 @@ class EmailLoginNotificationTest extends UnitTestCase protected function setUpMailMessageProphecy() { $mailMessage = $this->prophesize(FluidEmail::class); - $mailMessage->subject(Argument::any())->willReturn($mailMessage->reveal()); $mailMessage->to(Argument::any())->willReturn($mailMessage->reveal()); $mailMessage->setTemplate(Argument::any())->willReturn($mailMessage->reveal()); $mailMessage->from(Argument::any())->willReturn($mailMessage->reveal()); diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-90266-Fluid-basedTemplatedEmails.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-90266-Fluid-basedTemplatedEmails.rst index 10fb163b9b9cc3e3f5a8de30e2c9185bc102df1c..b0fb32ddd42d3d206a324c450e6080439f93eb13 100644 --- a/typo3/sysext/core/Documentation/Changelog/master/Feature-90266-Fluid-basedTemplatedEmails.rst +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-90266-Fluid-basedTemplatedEmails.rst @@ -31,6 +31,8 @@ set this in your LocalConfiguration.php / AdditionalConfiguration.php file: * :php:`$GLOBALS['TYPO3_CONF_VARS']['MAIL']['templateRootPaths'][700] = 'EXT:my_site_extension/Resources/Private/Templates/Email';` * :php:`$GLOBALS['TYPO3_CONF_VARS']['MAIL']['layoutRootPaths'][700] = 'EXT:my_site_extension/Resources/Private/Layouts';` +In addition, it is possible to define a section within the Fluid email, +which - if defined - takes precedence over the :php:`subject()` method. In addition, it is possible to define a section within the Fluid email, which - if set - takes precedence over the :php:`subject()` method.