web/lib/Zend/Mail/Protocol/Abstract.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    14  * to license@zend.com so we can send you a copy immediately.
    14  * to license@zend.com so we can send you a copy immediately.
    15  *
    15  *
    16  * @category   Zend
    16  * @category   Zend
    17  * @package    Zend_Mail
    17  * @package    Zend_Mail
    18  * @subpackage Protocol
    18  * @subpackage Protocol
    19  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    21  * @version    $Id: Abstract.php 22602 2010-07-16 22:37:31Z freak $
    21  * @version    $Id: Abstract.php 24593 2012-01-05 20:35:02Z matthew $
    22  */
    22  */
    23 
    23 
    24 
    24 
    25 /**
    25 /**
    26  * @see Zend_Validate
    26  * @see Zend_Validate
    40  * Provides low-level methods for concrete adapters to communicate with a remote mail server and track requests and responses.
    40  * Provides low-level methods for concrete adapters to communicate with a remote mail server and track requests and responses.
    41  *
    41  *
    42  * @category   Zend
    42  * @category   Zend
    43  * @package    Zend_Mail
    43  * @package    Zend_Mail
    44  * @subpackage Protocol
    44  * @subpackage Protocol
    45  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    45  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    46  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    46  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    47  * @version    $Id: Abstract.php 22602 2010-07-16 22:37:31Z freak $
    47  * @version    $Id: Abstract.php 24593 2012-01-05 20:35:02Z matthew $
    48  * @todo Implement proxy settings
    48  * @todo Implement proxy settings
    49  */
    49  */
    50 abstract class Zend_Mail_Protocol_Abstract
    50 abstract class Zend_Mail_Protocol_Abstract
    51 {
    51 {
    52     /**
    52     /**
   159     {
   159     {
   160         $this->_disconnect();
   160         $this->_disconnect();
   161     }
   161     }
   162 
   162 
   163     /**
   163     /**
   164      * Set the maximum log size 
   164      * Set the maximum log size
   165      * 
   165      *
   166      * @param integer $maximumLog Maximum log size
   166      * @param integer $maximumLog Maximum log size
   167      * @return void
   167      * @return void
   168      */
   168      */
   169     public function setMaximumLog($maximumLog)
   169     public function setMaximumLog($maximumLog)
   170     {
   170     {
   171         $this->_maximumLog = (int) $maximumLog;
   171         $this->_maximumLog = (int) $maximumLog;
   172     }
   172     }
   173     
   173 
   174     
   174 
   175     /**
   175     /**
   176      * Get the maximum log size 
   176      * Get the maximum log size
   177      * 
   177      *
   178      * @return int the maximum log size
   178      * @return int the maximum log size
   179      */
   179      */
   180     public function getMaximumLog()
   180     public function getMaximumLog()
   181     {
   181     {
   182         return $this->_maximumLog;
   182         return $this->_maximumLog;
   183     }
   183     }
   184     
   184 
   185 
   185 
   186     /**
   186     /**
   187      * Create a connection to the remote host
   187      * Create a connection to the remote host
   188      *
   188      *
   189      * Concrete adapters for this class will implement their own unique connect scripts, using the _connect() method to create the socket resource.
   189      * Concrete adapters for this class will implement their own unique connect scripts, using the _connect() method to create the socket resource.
   275              */
   275              */
   276             require_once 'Zend/Mail/Protocol/Exception.php';
   276             require_once 'Zend/Mail/Protocol/Exception.php';
   277             throw new Zend_Mail_Protocol_Exception($errorStr);
   277             throw new Zend_Mail_Protocol_Exception($errorStr);
   278         }
   278         }
   279 
   279 
   280         if (($result = stream_set_timeout($this->_socket, self::TIMEOUT_CONNECTION)) === false) {
   280         if (($result = $this->_setStreamTimeout(self::TIMEOUT_CONNECTION)) === false) {
   281             /**
   281             /**
   282              * @see Zend_Mail_Protocol_Exception
   282              * @see Zend_Mail_Protocol_Exception
   283              */
   283              */
   284             require_once 'Zend/Mail/Protocol/Exception.php';
   284             require_once 'Zend/Mail/Protocol/Exception.php';
   285             throw new Zend_Mail_Protocol_Exception('Could not set stream timeout');
   285             throw new Zend_Mail_Protocol_Exception('Could not set stream timeout');
   355             throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host);
   355             throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host);
   356         }
   356         }
   357 
   357 
   358         // Adapters may wish to supply per-commend timeouts according to appropriate RFC
   358         // Adapters may wish to supply per-commend timeouts according to appropriate RFC
   359         if ($timeout !== null) {
   359         if ($timeout !== null) {
   360            stream_set_timeout($this->_socket, $timeout);
   360             $this->_setStreamTimeout($timeout);
   361         }
   361         }
   362 
   362 
   363         // Retrieve response
   363         // Retrieve response
   364         $reponse = fgets($this->_socket, 1024);
   364         $reponse = fgets($this->_socket, 1024);
   365 
   365 
   426         if ($errMsg !== '') {
   426         if ($errMsg !== '') {
   427             /**
   427             /**
   428              * @see Zend_Mail_Protocol_Exception
   428              * @see Zend_Mail_Protocol_Exception
   429              */
   429              */
   430             require_once 'Zend/Mail/Protocol/Exception.php';
   430             require_once 'Zend/Mail/Protocol/Exception.php';
   431             throw new Zend_Mail_Protocol_Exception($errMsg);
   431             throw new Zend_Mail_Protocol_Exception($errMsg, $cmd);
   432         }
   432         }
   433 
   433 
   434         return $msg;
   434         return $msg;
   435     }
   435     }
       
   436 
       
   437     /**
       
   438      * Set stream timeout
       
   439      *
       
   440      * @param integer $timeout
       
   441      * @return boolean
       
   442      */
       
   443     protected function _setStreamTimeout($timeout)
       
   444     {
       
   445        return stream_set_timeout($this->_socket, $timeout);
       
   446     }
   436 }
   447 }