mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-15 09:34:09 +02:00
Adding a new maxColumnWidth property see #217
This commit is contained in:
@@ -25,6 +25,7 @@ class NativeMailerHandler extends MailHandler
|
|||||||
protected $headers = array(
|
protected $headers = array(
|
||||||
'Content-type: text/plain; charset=utf-8'
|
'Content-type: text/plain; charset=utf-8'
|
||||||
);
|
);
|
||||||
|
protected $maxColumnWidth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|array $to The receiver of the mail
|
* @param string|array $to The receiver of the mail
|
||||||
@@ -32,13 +33,15 @@ class NativeMailerHandler extends MailHandler
|
|||||||
* @param string $from The sender of the mail
|
* @param string $from The sender of the mail
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
|
* @param int $maxColumnWidth The maximum column width that the message lines will have
|
||||||
*/
|
*/
|
||||||
public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true)
|
public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true, $maxColumnWidth = 70)
|
||||||
{
|
{
|
||||||
parent::__construct($level, $bubble);
|
parent::__construct($level, $bubble);
|
||||||
$this->to = is_array($to) ? $to : array($to);
|
$this->to = is_array($to) ? $to : array($to);
|
||||||
$this->subject = $subject;
|
$this->subject = $subject;
|
||||||
$this->addHeader(sprintf('From: %s', $from));
|
$this->addHeader(sprintf('From: %s', $from));
|
||||||
|
$this->maxColumnWidth = $maxColumnWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +62,7 @@ class NativeMailerHandler extends MailHandler
|
|||||||
*/
|
*/
|
||||||
protected function send($content, array $records)
|
protected function send($content, array $records)
|
||||||
{
|
{
|
||||||
$content = wordwrap($content, 70);
|
$content = wordwrap($content, $this->maxColumnWidth);
|
||||||
$headers = implode("\r\n", $this->headers) . "\r\n";
|
$headers = implode("\r\n", $this->headers) . "\r\n";
|
||||||
foreach ($this->to as $to) {
|
foreach ($this->to as $to) {
|
||||||
mail($to, $this->subject, $content, $headers);
|
mail($to, $this->subject, $content, $headers);
|
||||||
|
Reference in New Issue
Block a user