123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..');
-
- require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php');
- require_once(LOG4PHP_DIR . '/LoggerLog.php');
- class LoggerAppenderMail extends LoggerAppenderSkeleton {
-
- var $from = null;
-
- var $subject = 'Log4php Report';
-
-
- var $to = null;
-
- var $body = '';
-
-
- var $requiresLayout = true;
-
-
- function LoggerAppenderMail($name)
- {
- $this->LoggerAppenderSkeleton($name);
- }
- function activateOptions()
- {
- $this->closed = false;
- return;
- }
-
- function close()
- {
- $from = $this->getFrom();
- $to = $this->getTo();
- if (!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) {
- $subject = $this->getSubject();
- LoggerLog::debug("LoggerAppenderMail::close() sending mail from=[{$from}] to=[{$to}] subject=[{$subject}]");
-
- @mail(
- $to, $subject,
- $this->layout->getHeader() . $this->body . $this->layout->getFooter(),
- "From: {$from}\r\n"
- );
- }
- $this->closed = true;
- }
-
-
- function getFrom()
- {
- return $this->from;
- }
-
-
- function getSubject()
- {
- return $this->subject;
- }
-
- function getTo()
- {
- return $this->to;
- }
-
- function setSubject($subject)
- {
- $this->subject = $subject;
- }
-
- function setTo($to)
- {
- $this->to = $to;
- }
- function setFrom($from)
- {
- $this->from = $from;
- }
- function append($event)
- {
- if ($this->layout !== null)
- $this->body .= $this->layout->format($event);
- }
- }
- ?>
|