119 function Log_mail($name, $ident =
'', $conf = array(),
122 $this->_id = md5(microtime());
123 $this->_recipients = $name;
124 $this->_ident = $ident;
127 if (!empty($conf[
'from'])) {
128 $this->_from = $conf[
'from'];
130 $this->_from = ini_get(
'sendmail_from');
133 if (!empty($conf[
'subject'])) {
134 $this->_subject = $conf[
'subject'];
137 if (!empty($conf[
'preamble'])) {
138 $this->_preamble = $conf[
'preamble'];
141 if (!empty($conf[
'lineFormat'])) {
142 $this->_lineFormat = str_replace(array_keys($this->_formatMap),
143 array_values($this->_formatMap),
144 $conf[
'lineFormat']);
147 if (!empty($conf[
'timeFormat'])) {
148 $this->_timeFormat = $conf[
'timeFormat'];
151 if (!empty($conf[
'mailBackend'])) {
152 $this->_mailBackend = $conf[
'mailBackend'];
155 if (!empty($conf[
'mailParams'])) {
156 $this->_mailParams = $conf[
'mailParams'];
160 register_shutdown_function(array(&$this,
'_Log_mail'));
181 if (!$this->_opened) {
182 if (!empty($this->_preamble)) {
183 $this->_message = $this->_preamble .
"\r\n\r\n";
185 $this->_opened =
true;
200 if ($this->_opened) {
201 if ($this->_shouldSend && !empty($this->_message)) {
202 if ($this->_mailBackend ===
'') {
203 $headers =
"From: $this->_from\r\n";
204 $headers .=
'User-Agent: PEAR Log Package';
205 if (mail($this->_recipients, $this->_subject,
206 $this->_message, $headers) ==
false) {
210 include_once
'Mail.php';
211 $headers = array(
'From' => $this->_from,
212 'To' => $this->_recipients,
213 'User-Agent' =>
'PEAR Log Package',
214 'Subject' => $this->_subject);
217 $res = $mailer->send($this->_recipients, $headers,
225 $this->_message =
'';
226 $this->_shouldSend =
false;
228 $this->_opened =
false;
231 return ($this->_opened ===
false);
248 return $this->
close();
263 function log($message, $priority = null)
266 if ($priority === null) {
276 if (!$this->_opened && !$this->
open()) {
284 $this->_message .= $this->
_format($this->_lineFormat,
285 strftime($this->_timeFormat),
286 $priority, $message) .
"\r\n";
287 $this->_shouldSend =
true;
290 $this->
_announce(array(
'priority' => $priority,
'message' => $message));