Changeset d78c417 in github
- Timestamp:
- Dec 18, 2008 1:34:50 PM (4 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- e275ce6
- Parents:
- b751d56
- File:
-
- 1 edited
-
program/lib/Net/SMTP.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/lib/Net/SMTP.php
rb751d56 rd78c417 66 66 67 67 /** 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 /** 68 88 * Should debugging output be enabled? 69 89 * @var boolean … … 114 134 * @param integer $port The port to connect to. 115 135 * @param string $localhost The value to give when sending EHLO or HELO. 136 * @param boolean $pipeling Use SMTP command pipelining 116 137 * 117 138 * @access public 118 139 * @since 1.0 119 140 */ 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; 125 153 126 154 $this->_socket = new Net_Socket(); 127 155 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. */ 132 159 if ((@include_once 'Auth/SASL.php') === false) { 133 160 $pos = array_search('DIGEST-MD5', $this->auth_methods); … … 212 239 * may be specified as an array of integer 213 240 * 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 214 244 * 215 245 * @return mixed True if the server returned a valid response code or … … 221 251 * @see getResponse 222 252 */ 223 function _parseResponse($valid )253 function _parseResponse($valid, $later = false) 224 254 { 225 255 $this->_code = -1; 226 256 $this->_arguments = array(); 227 257 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. */ 258 297 if (is_int($valid) && ($this->_code === $valid)) { 259 298 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; 269 301 } 270 302 … … 382 414 strlen($argument) - strlen($verb) - 1); 383 415 $this->_esmtp[$verb] = $arguments; 416 } 417 418 if (!isset($this->_esmtp['PIPELINING'])) { 419 $this->pipelining = false; 384 420 } 385 421 … … 688 724 689 725 /** 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 /** 690 738 * Send the MAIL FROM: command. 691 739 * … … 727 775 return $error; 728 776 } 729 if (PEAR::isError($error = $this->_parseResponse(250 ))) {777 if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 730 778 return $error; 731 779 } … … 757 805 return $error; 758 806 } 759 if (PEAR::isError($error = $this->_parseResponse(array(250, 251) ))) {807 if (PEAR::isError($error = $this->_parseResponse(array(250, 251), $this->pipelining))) { 760 808 return $error; 761 809 } … … 826 874 return $result; 827 875 } 828 if (PEAR::isError($error = $this->_parseResponse(250 ))) {876 if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 829 877 return $error; 830 878 } … … 848 896 return $error; 849 897 } 850 if (PEAR::isError($error = $this->_parseResponse(250 ))) {898 if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 851 899 return $error; 852 900 } … … 887 935 return $error; 888 936 } 889 if (PEAR::isError($error = $this->_parseResponse(250 ))) {937 if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 890 938 return $error; 891 939 } … … 926 974 return $error; 927 975 } 928 if (PEAR::isError($error = $this->_parseResponse(250 ))) {976 if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 929 977 return $error; 930 978 } … … 963 1011 return $error; 964 1012 } 965 if (PEAR::isError($error = $this->_parseResponse(250 ))) {1013 if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { 966 1014 return $error; 967 1015 }
Note: See TracChangeset
for help on using the changeset viewer.
