Skip to content

Commit

Permalink
Logger: uses CRLF for mail headers [Closes #584]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 4, 2024
1 parent dd9bc1f commit 00b5060
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/Tracy/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}

0 comments on commit 00b5060

Please sign in to comment.