I believe the problem is that in the Install Tool > Environment, the framework doesn't really utilize Dependency Injection "properly", because it's in failsafe-mode.
Since probably utilizing "real DI" in this case won't work as intended, I'm afraid the fix might be to prevent calling the __destruct() method and sending mails when being inside the install tool context will very likely fail.
Here's a patch that would circument this, but I'm not sure in which cases the MemorySpool Mailer is currently broken, too. Maybe you want to check if regular mails still get sent with the patch applied (I think so).
Personally, I think the MemorySpool Mailer is not a good idea. It can easily lose mails. I'd strongly suggest to either use no spooler at all (and use a satellite mail relay on localhost) or the file spooler, which doesn't use __destruct
logic.
diff --git a/typo3/sysext/core/Classes/Mail/MemorySpool.php b/typo3/sysext/core/Classes/Mail/MemorySpool.php
index 5fee22ddba..a275d307ec 100644
--- a/typo3/sysext/core/Classes/Mail/MemorySpool.php
+++ b/typo3/sysext/core/Classes/Mail/MemorySpool.php
@@ -69,7 +69,13 @@ class MemorySpool extends AbstractTransport implements SingletonInterface, Delay
public function __destruct()
{
// TODO: DI should be used to inject the MailerInterface
- $mailer = GeneralUtility::makeInstance(MailerInterface::class);
+ try {
+ $mailer = GeneralUtility::makeInstance(MailerInterface::class);
+ } catch (\Throwable $exception) {
+ // Install Tool has no DI setup. Thus also $this->logger is not usable here. Just bail.
+ return;
+ }
+
try {
$this->flushQueue($mailer->getRealTransport());
} catch (TransportExceptionInterface $exception) {