mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/10076] Move EHLO/HELO code into its own method.
PHPBB3-10076
This commit is contained in:
parent
522090ab28
commit
ac492d8f1e
1 changed files with 39 additions and 23 deletions
|
@ -1286,30 +1286,10 @@ class smtp_class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try EHLO first
|
$hello_result = $this->hello($local_host);
|
||||||
$this->server_send("EHLO {$local_host}");
|
if (!is_null($hello_result))
|
||||||
if ($err_msg = $this->server_parse('250', __LINE__))
|
|
||||||
{
|
{
|
||||||
// a 503 response code means that we're already authenticated
|
return $hello_result;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are not authenticated yet, something might be wrong if no username and passwd passed
|
// If we are not authenticated yet, something might be wrong if no username and passwd passed
|
||||||
|
@ -1355,6 +1335,42 @@ class smtp_class
|
||||||
return $this->$method($username, $password);
|
return $this->$method($username, $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Pop before smtp authentication
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue