From 00b50603b8388ebcff4d97c3a2c27cf6a99dbff1 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 5 Oct 2024 01:07:26 +0200 Subject: [PATCH] Logger: uses CRLF for mail headers [Closes #584] --- src/Tracy/Logger/Logger.php | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Tracy/Logger/Logger.php b/src/Tracy/Logger/Logger.php index 4ef677798..8bf426301 100644 --- a/src/Tracy/Logger/Logger.php +++ b/src/Tracy/Logger/Logger.php @@ -180,21 +180,16 @@ protected function sendEmail($message): void public function defaultMailer($message, string $email): void { $host = preg_replace('#[^\w.-]+#', '', $_SERVER['SERVER_NAME'] ?? php_uname('n')); - $parts = str_replace( - ["\r\n", "\n"], - ["\n", PHP_EOL], - [ - 'headers' => implode("\n", [ - 'From: ' . ($this->fromEmail ?: "noreply@$host"), - 'X-Mailer: Tracy', - 'Content-Type: text/plain; charset=UTF-8', - 'Content-Transfer-Encoding: 8bit', - ]) . "\n", - 'subject' => "PHP: An error occurred on the server $host", - 'body' => static::formatMessage($message) . "\n\nsource: " . Helpers::getSource(), - ], + mail( + $email, + "PHP: An error occurred on the server $host", + static::formatMessage($message) . "\n\nsource: " . Helpers::getSource(), + implode("\r\n", [ + 'From: ' . ($this->fromEmail ?: "noreply@$host"), + 'X-Mailer: Tracy', + 'Content-Type: text/plain; charset=UTF-8', + 'Content-Transfer-Encoding: 8bit', + ]), ); - - mail($email, $parts['subject'], $parts['body'], $parts['headers']); } }