cvs: pearweb /include/Damblan/Log Mail.php

From: Date: Wed, 15 Oct 2003 20:15:25 +0000
Subject: cvs: pearweb /include/Damblan/Log Mail.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-13642@lists.php.net to get a copy of this message
mj Wed Oct 15 16:15:25 2003 EDT Modified files: /pearweb/include/Damblan/Log Mail.php Log: * Instead of constructing the mail on our own, we are now using the Mail package to do the job. Index: pearweb/include/Damblan/Log/Mail.php diff -u pearweb/include/Damblan/Log/Mail.php:1.1 pearweb/include/Damblan/Log/Mail.php:1.2 --- pearweb/include/Damblan/Log/Mail.php:1.1 Wed Oct 15 16:02:12 2003 +++ pearweb/include/Damblan/Log/Mail.php Wed Oct 15 16:15:25 2003 @@ -15,27 +15,37 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Mail.php,v 1.1 2003/10/15 20:02:12 mj Exp $ + $Id: Mail.php,v 1.2 2003/10/15 20:15:25 mj Exp $ */ require_once "Log.php"; require_once "Log/observer.php"; +require_once "Mail.php"; + /** * Observer class for logging via email * * @author Martin Jansen <mj@php.net> * @extends Log_observer - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @package Damblan */ class Damblan_Log_Mail extends Log_observer { + var $_mailer = null; + + var $_headers = array(); var $_recipients = ""; - var $_from = "\"PEAR System Administrators\" <pear-sys@php.net>"; - var $_reply_to = ""; - var $_subject = ""; + function Damblan_Log_Mail() { + $this->Log_observer(); + + $this->_mailer =& Mail::factory("mail", "-f pear-sys@php.net"); + + $this->_headers['From'] = "\"PEAR System Administrators\" <pear-sys@php.net>"; + } + /** * Generate logging email * @@ -43,13 +53,7 @@ * @return void */ function notify($event) { - $headers = "From: " . $this->_from; - if (!empty($this->_reply_to)) { - $headers .= "\r\nReply-To: " . $this->_reply_to; - } - - $ok = mail($this->_recipients, $this->_subject, $event['message'], - $headers, "-f pear-sys@php.net"); + $ok = $this->_mailer->send($this->_recipients, $this->_headers, $event['message']); if ($ok === false) { trigger_error("Email notification routine failed.", @@ -69,36 +73,15 @@ } /** - * Set mail sender - * - * @access public - * @param string From line - * @return void - */ - function setFrom($f) { - $this->_from = $f; - } - - /** - * Set mail sender - * - * @access public - * @param string From line - * @return void - */ - function setReplyTo($r) { - $this->_reply_to = $r; - } - - /** - * Set mail subject + * Set header line * * @access public - * @param string Subject + * @param string Name of the header (e.g. "From") + * @param string Value of the header * @return void */ - function setSubject($s) { - $this->_subject = $s; + function setHeader($name, $value) { + $this->_headers[$name] = $value; } } ?>

« previous php.pear.cvs (#13642) next »