|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Monolog package. |
|
|
5 |
* |
|
|
6 |
* (c) Jordi Boggiano <j.boggiano@seld.be> |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Monolog\Handler; |
|
|
13 |
|
|
|
14 |
use Monolog\Logger; |
|
|
15 |
|
|
|
16 |
/** |
|
|
17 |
* NativeMailerHandler uses the mail() function to send the emails |
|
|
18 |
* |
|
|
19 |
* @author Christophe Coevoet <stof@notk.org> |
|
|
20 |
*/ |
|
|
21 |
class NativeMailerHandler extends MailHandler |
|
|
22 |
{ |
|
|
23 |
protected $to; |
|
|
24 |
protected $subject; |
|
|
25 |
protected $headers; |
|
|
26 |
|
|
|
27 |
/** |
|
|
28 |
* @param string $to The receiver of the mail |
|
|
29 |
* @param string $subject The subject of the mail |
|
|
30 |
* @param string $from The sender of the mail |
|
|
31 |
* @param integer $level The minimum logging level at which this handler will be triggered |
|
|
32 |
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not |
|
|
33 |
*/ |
|
|
34 |
public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true) |
|
|
35 |
{ |
|
|
36 |
parent::__construct($level, $bubble); |
|
|
37 |
$this->to = $to; |
|
|
38 |
$this->subject = $subject; |
|
|
39 |
$this->headers = sprintf("From: %s\r\nContent-type: text/plain; charset=utf-8\r\n", $from); |
|
|
40 |
} |
|
|
41 |
|
|
|
42 |
/** |
|
|
43 |
* {@inheritdoc} |
|
|
44 |
*/ |
|
|
45 |
protected function send($content) |
|
|
46 |
{ |
|
|
47 |
mail($this->to, $this->subject, wordwrap($content, 70), $this->headers); |
|
|
48 |
} |
|
|
49 |
} |