cvs: pear /Net_SMTP SMTP.php

From: Date: Wed, 15 Jan 2003 03:56:43 +0000
Subject: cvs: pear /Net_SMTP SMTP.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8267@lists.php.net to get a copy of this message
jon Tue Jan 14 22:56:43 2003 EDT Modified files: /pear/Net_SMTP SMTP.php Log: identifySender() has been renamed to _negotiate(). RFC-2554 requires us to re-negotiate ESMTP after an AUTH. The Mail/smtp class does this, but it is more desirable to handle this internally. There is now no reason for the identifySender() / _negotiate() method to be called externally, so it has become private. The internal callers have also been changed to test for and return a PEAR_Error error object should _negotiate() fail. Index: pear/Net_SMTP/SMTP.php diff -u pear/Net_SMTP/SMTP.php:1.24 pear/Net_SMTP/SMTP.php:1.25 --- pear/Net_SMTP/SMTP.php:1.24 Mon Jan 13 23:36:03 2003 +++ pear/Net_SMTP/SMTP.php Tue Jan 14 22:56:42 2003 @@ -264,8 +264,8 @@ if (PEAR::isError($error = $this->_parseResponse(220))) { return $error; } - if (!$this->identifySender()) { - return new PEAR_Error('unable to identify smtp server'); + if (PEAR::isError($error = $this->_negotiate())) { + return $error; } return true; @@ -295,6 +295,41 @@ } /** + * Attempt to send the EHLO command and obtain a list of ESMTP + * extensions available, and failing that just send HELO. + * + * @return mixed Returns a PEAR_Error with an error message on any + * kind of failure, or true on success. + * @access private + */ + function _negotiate() + { + if (PEAR::isError($error = $this->_put('EHLO', $this->localhost))) { + return $error; + } + + if (PEAR::isError($this->_parseResponse(250))) { + if (PEAR::isError($error = $this->_put('HELO', $this->localhost))) { + return $error; + } + if (PEAR::isError($this->_parseResponse(250))) { + return new PEAR_Error('HELO was not accepted: ', $this->_code); + } + + return true; + } + + foreach ($this->_arguments as $argument) { + $verb = strtok($argument, ' '); + $arguments = substr($argument, strlen($verb) + 1, + strlen($argument) - strlen($verb) - 1); + $this->esmtp[$verb] = $arguments; + } + + return true; + } + + /** * Returns the name of the best authentication method that the server * has advertised. * @@ -370,6 +405,11 @@ return $result; } + /* RFC-2554 requires us to re-negotiate ESMTP after an AUTH. */ + if (PEAR::isError($error = $this->_negotiate())) { + return $error; + } + return true; } @@ -751,37 +791,14 @@ } /** - * Attempt to send the EHLO command and obtain a list of ESMTP - * extensions available, and failing that just send HELO. + * Backwards-compatibility method. identifySender()'s functionality is + * now handled internally. * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access private + * @return boolean This method always return true. + * @access public */ function identifySender() { - if (PEAR::isError($error = $this->_put('EHLO', $this->localhost))) { - return $error; - } - - if (PEAR::isError($this->_parseResponse(250))) { - if (PEAR::isError($error = $this->_put('HELO', $this->localhost))) { - return $error; - } - if (PEAR::isError($this->_parseResponse(250))) { - return new PEAR_Error('HELO was not accepted: ', $this->_code); - } - - return true; - } - - foreach ($this->_arguments as $argument) { - $verb = strtok($argument, ' '); - $arguments = substr($argument, strlen($verb) + 1, - strlen($argument) - strlen($verb) - 1); - $this->esmtp[$verb] = $arguments; - } - return true; } }

« previous php.pear.cvs (#8267) next »