Changeset 2180 in subversion


Ignore:
Timestamp:
Dec 18, 2008 1:34:50 PM (4 years ago)
Author:
alec
Message:

updated bundled Net_SMTP to 1.3.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/lib/Net/SMTP.php

    r2179 r2180  
    6666 
    6767    /** 
     68     * Use SMTP command pipelining (specified in RFC 2920) if the SMTP 
     69     * server supports it. 
     70     * 
     71     * When pipeling is enabled, rcptTo(), mailFrom(), sendFrom(), 
     72     * somlFrom() and samlFrom() do not wait for a response from the 
     73     * SMTP server but return immediately. 
     74     * 
     75     * @var bool 
     76     * @access public 
     77     */ 
     78    var $pipelining = false; 
     79 
     80    /** 
     81     * Number of pipelined commands. 
     82     * @var int 
     83     * @access private 
     84     */ 
     85    var $_pipelined_commands = 0; 
     86 
     87    /** 
    6888     * Should debugging output be enabled? 
    6989     * @var boolean 
     
    114134     * @param integer $port       The port to connect to. 
    115135     * @param string  $localhost  The value to give when sending EHLO or HELO. 
     136     * @param boolean $pipeling   Use SMTP command pipelining 
    116137     * 
    117138     * @access  public 
    118139     * @since   1.0 
    119140     */ 
    120     function Net_SMTP($host = null, $port = null, $localhost = null) 
    121     { 
    122         if (isset($host)) $this->host = $host; 
    123         if (isset($port)) $this->port = $port; 
    124         if (isset($localhost)) $this->localhost = $localhost; 
     141    function Net_SMTP($host = null, $port = null, $localhost = null, $pipelining = false) 
     142    { 
     143        if (isset($host)) { 
     144            $this->host = $host; 
     145        } 
     146        if (isset($port)) { 
     147            $this->port = $port; 
     148        } 
     149        if (isset($localhost)) { 
     150            $this->localhost = $localhost; 
     151        } 
     152        $this->pipelining = $pipelining; 
    125153 
    126154        $this->_socket = new Net_Socket(); 
    127155 
    128         /* 
    129          * Include the Auth_SASL package.  If the package is not available, 
    130          * we disable the authentication methods that depend upon it. 
    131          */ 
     156        /* Include the Auth_SASL package.  If the package is not 
     157         * available, we disable the authentication methods that 
     158         * depend upon it. */ 
    132159        if ((@include_once 'Auth/SASL.php') === false) { 
    133160            $pos = array_search('DIGEST-MD5', $this->auth_methods); 
     
    212239     *                              may be specified as an array of integer 
    213240     *                              values or as a single integer value. 
     241     * @param   bool    $later      Do not parse the response now, but wait 
     242     *                              until the last command in the pipelined 
     243     *                              command group 
    214244     * 
    215245     * @return  mixed   True if the server returned a valid response code or 
     
    221251     * @see     getResponse 
    222252     */ 
    223     function _parseResponse($valid) 
     253    function _parseResponse($valid, $later = false) 
    224254    { 
    225255        $this->_code = -1; 
    226256        $this->_arguments = array(); 
    227257 
    228         while ($line = $this->_socket->readLine()) { 
    229             if ($this->_debug) { 
    230                 echo "DEBUG: Recv: $line\n"; 
    231             } 
    232  
    233             /* If we receive an empty line, the connection has been closed. */ 
    234             if (empty($line)) { 
    235                 $this->disconnect(); 
    236                 return PEAR::raiseError('Connection was unexpectedly closed'); 
    237             } 
    238  
    239             /* Read the code and store the rest in the arguments array. */ 
    240             $code = substr($line, 0, 3); 
    241             $this->_arguments[] = trim(substr($line, 4)); 
    242  
    243             /* Check the syntax of the response code. */ 
    244             if (is_numeric($code)) { 
    245                 $this->_code = (int)$code; 
    246             } else { 
    247                 $this->_code = -1; 
    248                 break; 
    249             } 
    250  
    251             /* If this is not a multiline response, we're done. */ 
    252             if (substr($line, 3, 1) != '-') { 
    253                 break; 
    254             } 
    255         } 
    256  
    257         /* Compare the server's response code with the valid code. */ 
     258        if ($later) { 
     259            $this->_pipelined_commands++; 
     260            return true; 
     261        } 
     262 
     263        for ($i = 0; $i <= $this->_pipelined_commands; $i++) { 
     264            while ($line = $this->_socket->readLine()) { 
     265                if ($this->_debug) { 
     266                    echo "DEBUG: Recv: $line\n"; 
     267                } 
     268 
     269                /* If we receive an empty line, the connection has been closed. */ 
     270                if (empty($line)) { 
     271                    $this->disconnect(); 
     272                    return PEAR::raiseError('Connection was unexpectedly closed'); 
     273                } 
     274 
     275                /* Read the code and store the rest in the arguments array. */ 
     276                $code = substr($line, 0, 3); 
     277                $this->_arguments[] = trim(substr($line, 4)); 
     278 
     279                /* Check the syntax of the response code. */ 
     280                if (is_numeric($code)) { 
     281                    $this->_code = (int)$code; 
     282                } else { 
     283                    $this->_code = -1; 
     284                    break; 
     285                } 
     286 
     287                /* If this is not a multiline response, we're done. */ 
     288                if (substr($line, 3, 1) != '-') { 
     289                    break; 
     290                } 
     291            } 
     292        } 
     293 
     294        $this->_pipelined_commands = 0; 
     295 
     296        /* Compare the server's response code with the valid code/codes. */ 
    258297        if (is_int($valid) && ($this->_code === $valid)) { 
    259298            return true; 
    260         } 
    261  
    262         /* If we were given an array of valid response codes, check each one. */ 
    263         if (is_array($valid)) { 
    264             foreach ($valid as $valid_code) { 
    265                 if ($this->_code === $valid_code) { 
    266                     return true; 
    267                 } 
    268             } 
     299        } elseif (is_array($valid) && in_array($this->_code, $valid, true)) { 
     300            return true; 
    269301        } 
    270302 
     
    382414                                strlen($argument) - strlen($verb) - 1); 
    383415            $this->_esmtp[$verb] = $arguments; 
     416        } 
     417 
     418        if (!isset($this->_esmtp['PIPELINING'])) { 
     419            $this->pipelining = false; 
    384420        } 
    385421 
     
    688724 
    689725    /** 
     726     * Return the list of SMTP service extensions advertised by the server. 
     727     * 
     728     * @return array The list of SMTP service extensions. 
     729     * @access public 
     730     * @since 1.3 
     731     */ 
     732    function getServiceExtensions() 
     733    { 
     734        return $this->_esmtp; 
     735    } 
     736 
     737    /** 
    690738     * Send the MAIL FROM: command. 
    691739     * 
     
    727775            return $error; 
    728776        } 
    729         if (PEAR::isError($error = $this->_parseResponse(250))) { 
     777        if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 
    730778            return $error; 
    731779        } 
     
    757805            return $error; 
    758806        } 
    759         if (PEAR::isError($error = $this->_parseResponse(array(250, 251)))) { 
     807        if (PEAR::isError($error = $this->_parseResponse(array(250, 251), $this->pipelining))) { 
    760808            return $error; 
    761809        } 
     
    826874            return $result; 
    827875        } 
    828         if (PEAR::isError($error = $this->_parseResponse(250))) { 
     876        if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 
    829877            return $error; 
    830878        } 
     
    848896            return $error; 
    849897        } 
    850         if (PEAR::isError($error = $this->_parseResponse(250))) { 
     898        if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 
    851899            return $error; 
    852900        } 
     
    887935            return $error; 
    888936        } 
    889         if (PEAR::isError($error = $this->_parseResponse(250))) { 
     937        if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 
    890938            return $error; 
    891939        } 
     
    926974            return $error; 
    927975        } 
    928         if (PEAR::isError($error = $this->_parseResponse(250))) { 
     976        if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 
    929977            return $error; 
    930978        } 
     
    9631011            return $error; 
    9641012        } 
    965         if (PEAR::isError($error = $this->_parseResponse(250))) { 
     1013        if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 
    9661014            return $error; 
    9671015        } 
Note: See TracChangeset for help on using the changeset viewer.