registry =& $registry; } /** * (PHP 4) Constructor */ function Mail(&$registry) { $this->__construct($registry); } /** * Sends an email to the specified address with the specified * sender, subject, and body. * * @access public * * @return bool Status of the message */ function send() { if (!@ini_get('sendmail_path')) { $this->registry->debug("email: no sendmail -> not sending"); return false; } $this->to = $this->_fetch_first_line($this->to); $this->from = $this->_fetch_first_line($this->from); if (!$this->from) { $this->registry->debug("email: no from -> not sending"); return false; } else { $this->from = trim($this->registry->unsanitize($this->from, true)); } if (!$this->fromname) { $this->fromname = $this->from; } else { $this->fromname = trim($this->registry->unsanitize($this->fromname, true)); } if (!$this->to) { $this->registry->debug("email: no recipient -> not sending"); return false; } else { $this->to = trim($this->registry->unsanitize($this->to)); } if (!$this->subject) { $this->registry->debug("email: no subject -> not sending"); return false; } else { $this->subject = trim($this->registry->unsanitize($this->_fetch_first_line($this->subject), true)); } if (!$this->body) { $this->registry->debug("email: no body -> not sending"); return false; } else { $this->body = $this->_convert_line_breaks($this->body); $this->body = trim($this->registry->unsanitize($this->body, true)); } $this->headers = $this->_convert_line_breaks($this->headers); $this->headers .= "From: \"{$this->fromname}\" <{$this->from}>\n"; $this->headers .= "Return-Path: {$this->from}\n"; $this->headers .= "X-Mailer: ISSO Mail Framework \$Revision$\n"; $this->headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; $this->headers .= "Content-Transfer-Encoding: 7bit\n"; if (mail($this->to, $this->subject, $this->body, trim($this->headers), "-f {$this->from}")) { $this->registry->debug("email: sent -> good"); return true; } else { $this->registry->debug("email: sent -> error"); return false; } } /** * Fetches the first line of a string * * @access private * * @param string A string * * @return string The first line of the string */ function _fetch_first_line($string) { $string = $this->_convert_line_breaks($string); $broken = explode("\n", $string); return $broken[0]; } /** * Changes line breaks into one format * * @access private * * @param string Text * @param string New line break (default is UNIX format) * * @return string Text with one type of line break */ function _convert_line_breaks($text, $convert_to = "\n") { $text = trim($text); $text = str_replace(array("\r\n", "\r", "\n"), "\n", $text); $text = str_replace("\n", $convert_to, $text); return $text; } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>