From 2ad4e119605f9a026972b69a85f7f049923b62a5 Mon Sep 17 00:00:00 2001 From: David Siegfried Date: Fri, 27 Feb 2026 14:30:48 +0100 Subject: use non-static mailer, re #2311 --- lib/classes/StudipMail.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/classes/StudipMail.php b/lib/classes/StudipMail.php index 7fb7eec..0081ccf 100644 --- a/lib/classes/StudipMail.php +++ b/lib/classes/StudipMail.php @@ -29,7 +29,7 @@ class StudipMail public const SMTP_TRANSPORTER = 'smtp'; - private static ?Mailer $mailer = null; + private ?Mailer $mailer; private static string $transporter; @@ -153,18 +153,16 @@ class StudipMail self::NULL_TRANSPORTER => 'null://null', default => $this->buildSmtpDsn() }; - if (!self::$mailer) { - if (self::getDefaultTransporter() === self::DEBUG_TRANSPORTER) { - $transport = new StudipDebugTransport( - $GLOBALS['TMP_PATH'] . '/' . - ($GLOBALS['DEBUG_MAIL_LOG_FILE_NAME'] ?? 'studip-mail-debug.log') - ); - } else { - $transport = Transport::fromDsn($dsn); - } - self::$mailer = new Mailer($transport); + if (self::getDefaultTransporter() === self::DEBUG_TRANSPORTER) { + $transport = new StudipDebugTransport( + $GLOBALS['TMP_PATH'] . '/' . + ($GLOBALS['DEBUG_MAIL_LOG_FILE_NAME'] ?? 'studip-mail-debug.log') + ); + } else { + $transport = Transport::fromDsn($dsn); } - $this->mailer = self::$mailer; + + $this->mailer = new Mailer($transport); $mail_localhost = $GLOBALS['MAIL_LOCALHOST'] ?: $_SERVER['SERVER_NAME']; $this->setSenderEmail($GLOBALS['MAIL_ENV_FROM'] ?: "wwwrun@{$mail_localhost}"); $this->setSenderName($GLOBALS['MAIL_FROM'] ?: 'Stud.IP - ' . Config::get()->UNI_NAME_CLEAN); -- cgit v1.0