Changeset 3e63a0b8 in github


Ignore:
Timestamp:
Mar 11, 2011 3:23:50 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
129aeff
Parents:
4591de7
Message:
  • PEAR::Net_SMTP 1.5.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r4591de7 r3e63a0b8  
    22=========================== 
    33 
     4- PEAR::Net_SMTP 1.5.1 
    45- Allow multiple concurrent compose sessions 
    56- Force names of unique constraints in PostgreSQL DDL 
  • program/lib/Net/SMTP.php

    r14015da r3e63a0b8  
    107107 
    108108    /** 
     109     * The socket I/O timeout value in seconds. 
     110     * @var int 
     111     * @access private 
     112     */ 
     113    var $_timeout = 0; 
     114 
     115    /** 
    109116     * The most recent server response code. 
    110117     * @var int 
     
    149156     * @param string  $localhost  The value to give when sending EHLO or HELO. 
    150157     * @param boolean $pipeling   Use SMTP command pipelining 
     158     * @param integer $timeout    Socket I/O timeout in seconds. 
    151159     * 
    152160     * @access  public 
    153161     * @since   1.0 
    154162     */ 
    155     function Net_SMTP($host = null, $port = null, $localhost = null, $pipelining = false) 
     163    function Net_SMTP($host = null, $port = null, $localhost = null, 
     164        $pipelining = false, $timeout = 0) 
    156165    { 
    157166        if (isset($host)) { 
     
    167176 
    168177        $this->_socket = new Net_Socket(); 
     178        $this->_timeout = $timeout; 
    169179 
    170180        /* Include the Auth_SASL package.  If the package is not 
     
    180190 
    181191    /** 
     192     * Set the socket I/O timeout value in seconds plus microseconds. 
     193     * 
     194     * @param   integer $seconds        Timeout value in seconds. 
     195     * @param   integer $microseconds   Additional value in microseconds. 
     196     * 
     197     * @access  public 
     198     * @since   1.5.0 
     199     */ 
     200    function setTimeout($seconds, $microseconds = 0) { 
     201        return $this->_socket->setTimeout($seconds, $microseconds); 
     202    } 
     203 
     204    /** 
    182205     * Set the value of the debugging flag. 
    183206     * 
     
    370393     * 
    371394     * @param   int     $timeout    The timeout value (in seconds) for the 
    372      *                              socket connection. 
     395     *                              socket connection attempt. 
    373396     * @param   bool    $persistent Should a persistent socket connection 
    374397     *                              be used? 
     
    387410            return PEAR::raiseError('Failed to connect socket: ' . 
    388411                                    $result->getMessage()); 
     412        } 
     413 
     414        /* 
     415         * Now that we're connected, reset the socket's timeout value for  
     416         * future I/O operations.  This allows us to have different socket  
     417         * timeout values for the initial connection (our $timeout parameter)  
     418         * and all other socket operations. 
     419         */ 
     420        if (PEAR::isError($error = $this->setTimeout($this->_timeout))) { 
     421            return $error; 
    389422        } 
    390423 
     
    618651        $digest = &Auth_SASL::factory('digestmd5'); 
    619652        $auth_str = base64_encode($digest->getResponse($uid, $pwd, $challenge, 
    620                                                        $this->host, "smtp", $authz)); 
     653                                                       $this->host, "smtp", 
     654                                                       $authz)); 
    621655 
    622656        if (PEAR::isError($error = $this->_put($auth_str))) { 
     
    831865                $args .= ' XVERP=' . $params['verp']; 
    832866            } 
    833         } elseif (is_string($params)) { 
     867        } elseif (is_string($params) && !empty($params)) { 
    834868            $args .= ' ' . $params; 
    835869        } 
     
    920954        } 
    921955 
    922         /* RFC 1870, section 3, subsection 3 states "a value of zero 
    923          * indicates that no fixed maximum message size is in force". 
    924          * Furthermore, it says that if "the parameter is omitted no 
    925          * information is conveyed about the server's fixed maximum 
    926          * message size". */ 
    927         if (isset($this->_esmtp['SIZE']) && ($this->_esmtp['SIZE'] > 0)) { 
    928             /* Start by considering the size of the optional headers string.   
    929              * We also account for the addition 4 character "\r\n\r\n" 
    930              * separator sequence. */ 
    931             $size = (is_null($headers)) ? 0 : strlen($headers) + 4; 
    932  
    933             if (is_resource($data)) { 
    934                 $stat = fstat($data); 
    935                 if ($stat === false) { 
    936                     return PEAR::raiseError('Failed to get file size'); 
    937                 } 
    938                 $size += $stat['size']; 
    939             } else { 
    940                 $size += strlen($data); 
    941             } 
    942  
    943             if ($size >= $this->_esmtp['SIZE']) { 
    944                 $this->disconnect(); 
    945                 return PEAR::raiseError('Message size exceeds server limit'); 
    946             } 
     956        /* Start by considering the size of the optional headers string.  We 
     957         * also account for the addition 4 character "\r\n\r\n" separator 
     958         * sequence. */ 
     959        $size = (is_null($headers)) ? 0 : strlen($headers) + 4; 
     960 
     961        if (is_resource($data)) { 
     962            $stat = fstat($data); 
     963            if ($stat === false) { 
     964                return PEAR::raiseError('Failed to get file size'); 
     965            } 
     966            $size += $stat['size']; 
     967        } else { 
     968            $size += strlen($data); 
     969        } 
     970 
     971        /* RFC 1870, section 3, subsection 3 states "a value of zero indicates 
     972         * that no fixed maximum message size is in force".  Furthermore, it 
     973         * says that if "the parameter is omitted no information is conveyed 
     974         * about the server's fixed maximum message size". */ 
     975        $limit = (isset($this->_esmtp['SIZE'])) ? $this->_esmtp['SIZE'] : 0; 
     976        if ($limit > 0 && $size >= $limit) { 
     977            $this->disconnect(); 
     978            return PEAR::raiseError('Message size exceeds server limit'); 
    947979        } 
    948980 
     
    9751007            } 
    9761008        } else { 
    977             if (!isset($size)) 
    978                 $size = strlen($data); 
    9791009            /* 
    9801010             * Break up the data by sending one chunk (up to 512k) at a time.   
Note: See TracChangeset for help on using the changeset viewer.