Skip to content

Commit

Permalink
Merge pull request #7 from AppsDevTeam/use-only-our-defaultMailer
Browse files Browse the repository at this point in the history
Update ErrorLogger.php
  • Loading branch information
thorewi authored Sep 22, 2020
2 parents 572e176 + 81bec01 commit dea92f0
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/ErrorLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Tracy\Dumper;
use Tracy\Helpers;


class ErrorLogger extends \Tracy\Logger
{
/**
Expand Down Expand Up @@ -247,20 +246,11 @@ public function log($message, $priority = self::INFO)
*/
public function defaultMailer($message, string $email, $attachment = NULL): void
{
if ($attachment === NULL) {
parent::defaultMailer($message, $email);
return;
}

$host = preg_replace('#[^\w.-]+#', '', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : php_uname('n'));

$separator = md5(time());
$eol = "\n";

$filename = basename($attachment);
$content = file_get_contents($attachment);
$content = chunk_split(base64_encode($content));

$body = '';
if ($this->includeErrorMessage) {
$body =
Expand All @@ -270,14 +260,17 @@ public function defaultMailer($message, string $email, $attachment = NULL): void
"Content-Type: text/plain; charset=\"UTF-8\"" . $eol .
"Content-Transfer-Encoding: 8bit" . $eol . $eol .
$this->formatMessage($message) . "\n\nsource: " . Helpers::getSource() . $eol .
"--" . $separator . $eol .

// Attachment
"Content-Type: application/octet-stream; name=\"" . $filename . "\"" . $eol .
"Content-Transfer-Encoding: base64" . $eol .
"Content-Disposition: attachment" . $eol . $eol .
$content . $eol .
"--" . $separator . "--";
"--" . $separator . $eol;

if ($attachment) {
$body .=
// Attachment
"Content-Type: application/octet-stream; name=\"" . basename($attachment) . "\"" . $eol .
"Content-Transfer-Encoding: base64" . $eol .
"Content-Disposition: attachment" . $eol . $eol .
chunk_split(base64_encode(file_get_contents($attachment))) . $eol .
"--" . $separator . "--";
}
}

$parts = str_replace(
Expand Down

0 comments on commit dea92f0

Please sign in to comment.