1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 17:16:18 +02:00

Add ability to use formatter in email subject lines

This commit is contained in:
Jordi Boggiano
2016-04-12 18:05:41 +01:00
parent 1fa91efc3b
commit a754edc64c
5 changed files with 63 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
namespace Monolog\Handler;
use Monolog\Logger;
use Monolog\Formatter\LineFormatter;
/**
* NativeMailerHandler uses the mail() function to send the emails
@@ -122,9 +123,16 @@ class NativeMailerHandler extends MailHandler
if ($this->getContentType() == 'text/html' && false === strpos($headers, 'MIME-Version:')) {
$headers .= 'MIME-Version: 1.0' . "\r\n";
}
$subject = $this->subject;
if ($records) {
$subjectFormatter = new LineFormatter($this->subject);
$subject = $subjectFormatter->format($this->getHighestRecord($records));
}
$parameters = implode(' ', $this->parameters);
foreach ($this->to as $to) {
mail($to, $this->subject, $content, $headers, $parameters);
mail($to, $subject, $content, $headers, $parameters);
}
}