Przeglądaj źródła

Merge pull request #222 from jmontoyaa/master

Adding a new maxColumnWidth property see #217
Jordi Boggiano 12 lat temu
rodzic
commit
32ff9a730a
1 zmienionych plików z 5 dodań i 2 usunięć
  1. 5 2
      src/Monolog/Handler/NativeMailerHandler.php

+ 5 - 2
src/Monolog/Handler/NativeMailerHandler.php

@@ -25,6 +25,7 @@ class NativeMailerHandler extends MailHandler
     protected $headers = array(
         'Content-type: text/plain; charset=utf-8'
     );
+    protected $maxColumnWidth;
 
     /**
      * @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 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 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);
         $this->to = is_array($to) ? $to : array($to);
         $this->subject = $subject;
         $this->addHeader(sprintf('From: %s', $from));
+        $this->maxColumnWidth = $maxColumnWidth;
     }
 
     /**
@@ -59,7 +62,7 @@ class NativeMailerHandler extends MailHandler
      */
     protected function send($content, array $records)
     {
-        $content = wordwrap($content, 70);
+        $content = wordwrap($content, $this->maxColumnWidth);
         $headers = implode("\r\n", $this->headers) . "\r\n";
         foreach ($this->to as $to) {
             mail($to, $this->subject, $content, $headers);