diff options
author | Andreas Fischer <bantu@phpbb.com> | 2011-08-22 23:33:34 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-01-28 22:51:34 +0100 |
commit | ac492d8f1e7ef3420ebaee35131e342a39dfda10 (patch) | |
tree | 9f8f1ef811bdb3c6ffb4b968e643d616cc00c1b1 | |
parent | 522090ab2821e0861304ecbcfc6ac26a5b5faeff (diff) | |
download | forums-ac492d8f1e7ef3420ebaee35131e342a39dfda10.tar forums-ac492d8f1e7ef3420ebaee35131e342a39dfda10.tar.gz forums-ac492d8f1e7ef3420ebaee35131e342a39dfda10.tar.bz2 forums-ac492d8f1e7ef3420ebaee35131e342a39dfda10.tar.xz forums-ac492d8f1e7ef3420ebaee35131e342a39dfda10.zip |
[ticket/10076] Move EHLO/HELO code into its own method.
PHPBB3-10076
-rw-r--r-- | phpBB/includes/functions_messenger.php | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 13d9b6a5cb..ccc17865f6 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -1286,30 +1286,10 @@ class smtp_class } } - // Try EHLO first - $this->server_send("EHLO {$local_host}"); - if ($err_msg = $this->server_parse('250', __LINE__)) + $hello_result = $this->hello($local_host); + if (!is_null($hello_result)) { - // a 503 response code means that we're already authenticated - if ($this->numeric_response_code == 503) - { - return false; - } - - // If EHLO fails, we try HELO - $this->server_send("HELO {$local_host}"); - if ($err_msg = $this->server_parse('250', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - } - - foreach ($this->responses as $response) - { - $response = explode(' ', $response); - $response_code = $response[0]; - unset($response[0]); - $this->commands[$response_code] = implode(' ', $response); + return $hello_result; } // If we are not authenticated yet, something might be wrong if no username and passwd passed @@ -1356,6 +1336,42 @@ class smtp_class } /** + * SMTP EHLO/HELO + * + * @return mixed Null if the authentication process is supposed to continue + * False if already authenticated + * Error message (string) otherwise + */ + protected function hello($hostname) + { + // Try EHLO first + $this->server_send("EHLO $hostname"); + if ($err_msg = $this->server_parse('250', __LINE__)) + { + // a 503 response code means that we're already authenticated + if ($this->numeric_response_code == 503) + { + return false; + } + + // If EHLO fails, we try HELO + $this->server_send("HELO $hostname"); + if ($err_msg = $this->server_parse('250', __LINE__)) + { + return ($this->numeric_response_code == 503) ? false : $err_msg; + } + } + + foreach ($this->responses as $response) + { + $response = explode(' ', $response); + $response_code = $response[0]; + unset($response[0]); + $this->commands[$response_code] = implode(' ', $response); + } + } + + /** * Pop before smtp authentication */ function pop_before_smtp($hostname, $username, $password) |