Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for Metafox/lib/Mail.php between version 1.3 and 1.4

version 1.3, 2005/11/07 22:24:36 version 1.4, 2011/11/22 16:06:58
Line 1 
Line 1 
 <?php  <?php
 //  /**
 // +----------------------------------------------------------------------+   *  PEAR's Mail:: interface.
 // | PHP Version 4                                                        |   *
 // +----------------------------------------------------------------------+   * PHP versions 4 and 5
 // | Copyright (c) 1997-2003 The PHP Group                                |   *
 // +----------------------------------------------------------------------+   * LICENSE:
 // | This source file is subject to version 2.02 of the PHP license,      |   *
 // | that is bundled with this package in the file LICENSE, and is        |   * Copyright (c) 2002-2007, Richard Heyes
 // | available at through the world-wide-web at                           |   * All rights reserved.
 // | http://www.php.net/license/2_02.txt.                                 |   *
 // | If you did not receive a copy of the PHP license and are unable to   |   * Redistribution and use in source and binary forms, with or without
 // | obtain it through the world-wide-web, please send a note to          |   * modification, are permitted provided that the following conditions
 // | license@php.net so we can mail you a copy immediately.               |   * are met:
 // +----------------------------------------------------------------------+   *
 // | Author: Chuck Hagenbuch <chuck@horde.org>                            |   * o Redistributions of source code must retain the above copyright
 // +----------------------------------------------------------------------+   *   notice, this list of conditions and the following disclaimer.
 //   * o Redistributions in binary form must reproduce the above copyright
 // $Id$   *   notice, this list of conditions and the following disclaimer in the
    *   documentation and/or other materials provided with the distribution.
    * o The names of the authors may not be used to endorse or promote
    *   products derived from this software without specific prior written
    *   permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    * @category    Mail
    * @package     Mail
    * @author      Chuck Hagenbuch <chuck@horde.org>
    * @copyright   1997-2010 Chuck Hagenbuch
    * @license     http://opensource.org/licenses/bsd-license.php New BSD License
    * @version     CVS: $Id$
    * @link        http://pear.php.net/package/Mail/
    */
   
 require_once 'PEAR.php';  require_once 'PEAR.php';
   
Line 82  class Mail
Line 107  class Mail
      * @return mixed Returns true on success, or a PEAR_Error       * @return mixed Returns true on success, or a PEAR_Error
      *               containing a descriptive error message on       *               containing a descriptive error message on
      *               failure.       *               failure.
        *
      * @access public       * @access public
      * @deprecated use Mail_mail::send instead       * @deprecated use Mail_mail::send instead
      */       */
     function send($recipients, $headers, $body)      function send($recipients, $headers, $body)
     {      {
           if (!is_array($headers)) {
               return PEAR::raiseError('$headers must be an array');
           }
   
           $result = $this->_sanitizeHeaders($headers);
           if (is_a($result, 'PEAR_Error')) {
               return $result;
           }
   
         // if we're passed an array of recipients, implode it.          // if we're passed an array of recipients, implode it.
         if (is_array($recipients)) {          if (is_array($recipients)) {
             $recipients = implode(', ', $recipients);              $recipients = implode(', ', $recipients);
Line 101  class Mail
Line 136  class Mail
         }          }
   
         // flatten the headers out.          // flatten the headers out.
         list(,$text_headers) = Mail::prepareHeaders($headers);          list(, $text_headers) = Mail::prepareHeaders($headers);
   
         return mail($recipients, $subject, $body, $text_headers);          return mail($recipients, $subject, $body, $text_headers);
       }
   
       /**
        * Sanitize an array of mail headers by removing any additional header
        * strings present in a legitimate header's value.  The goal of this
        * filter is to prevent mail injection attacks.
        *
        * @param array $headers The associative array of headers to sanitize.
        *
        * @access private
        */
       function _sanitizeHeaders(&$headers)
       {
           foreach ($headers as $key => $value) {
               $headers[$key] =
                   preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i',
                                null, $value);
           }
     }      }
   
     /**      /**
Line 131  class Mail
Line 183  class Mail
         foreach ($headers as $key => $value) {          foreach ($headers as $key => $value) {
             if (strcasecmp($key, 'From') === 0) {              if (strcasecmp($key, 'From') === 0) {
                 include_once 'Mail/RFC822.php';                  include_once 'Mail/RFC822.php';
                 $parser = &new Mail_RFC822();                  $parser = new Mail_RFC822();
                 $addresses = $parser->parseAddressList($value, 'localhost', false);                  $addresses = $parser->parseAddressList($value, 'localhost', false);
                 if (PEAR::isError($addresses)) {                  if (is_a($addresses, 'PEAR_Error')) {
                     return $addresses;                      return $addresses;
                 }                  }
   
Line 169  class Mail
Line 221  class Mail
             }              }
         }          }
   
         return array($from, join($this->sep, $lines) . $this->sep);          return array($from, join($this->sep, $lines));
     }      }
   
     /**      /**
Line 181  class Mail
Line 233  class Mail
      *              (RFC822 compliant), or an array of recipients,       *              (RFC822 compliant), or an array of recipients,
      *              each RFC822 valid.       *              each RFC822 valid.
      *       *
      * @return array An array of forward paths (bare addresses).       * @return mixed An array of forward paths (bare addresses) or a PEAR_Error
        *               object if the address list could not be parsed.
      * @access private       * @access private
      */       */
     function parseRecipients($recipients)      function parseRecipients($recipients)
Line 198  class Mail
Line 251  class Mail
         // for smtp recipients, etc. All relevant personal information          // for smtp recipients, etc. All relevant personal information
         // should already be in the headers.          // should already be in the headers.
         $addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);          $addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
   
           // If parseAddressList() returned a PEAR_Error object, just return it.
           if (is_a($addresses, 'PEAR_Error')) {
               return $addresses;
           }
   
         $recipients = array();          $recipients = array();
         if (is_array($addresses)) {          if (is_array($addresses)) {
             foreach ($addresses as $ob) {              foreach ($addresses as $ob) {

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top