mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 08:27:03 +03:00
Cleanup netClientLogin code
This commit is contained in:
parent
617d700a5d
commit
ed109740cd
3 changed files with 8 additions and 57 deletions
|
|
@ -153,8 +153,10 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
// $encrypted = !empty(\stream_get_meta_data($this->ConnectionResource())['crypto']);
|
// $encrypted = !empty(\stream_get_meta_data($this->ConnectionResource())['crypto']);
|
||||||
$type = $this->IsSupported('LOGINDISABLED') ? '' : 'LOGIN'; // RFC3501 6.2.3
|
$type = $this->IsSupported('LOGINDISABLED') ? '' : 'LOGIN'; // RFC3501 6.2.3
|
||||||
$types = [
|
$types = [
|
||||||
// 'SCRAM-SHA-256' => 1, // !$encrypted
|
// if !$encrypted:
|
||||||
// 'SCRAM-SHA-1' => 1, // !$encrypted
|
// 'SCRAM-SHA-256' => 1,
|
||||||
|
// 'SCRAM-SHA-1' => 1,
|
||||||
|
// if $encrypted:
|
||||||
'CRAM-MD5' => $aCredentials['UseAuthCramMd5IfSupported'],
|
'CRAM-MD5' => $aCredentials['UseAuthCramMd5IfSupported'],
|
||||||
'PLAIN' => $aCredentials['UseAuthPlainIfSupported'],
|
'PLAIN' => $aCredentials['UseAuthPlainIfSupported'],
|
||||||
'OAUTHBEARER' => $aCredentials['UseAuthOAuth2IfSupported'],
|
'OAUTHBEARER' => $aCredentials['UseAuthOAuth2IfSupported'],
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,10 @@ class SmtpClient extends \MailSo\Net\NetClient
|
||||||
// $encrypted = !empty(\stream_get_meta_data($this->ConnectionResource())['crypto']);
|
// $encrypted = !empty(\stream_get_meta_data($this->ConnectionResource())['crypto']);
|
||||||
$type = '';
|
$type = '';
|
||||||
$types = [
|
$types = [
|
||||||
'SCRAM-SHA-256' => 1, // !$encrypted
|
// if !$encrypted:
|
||||||
'SCRAM-SHA-1' => 1, // !$encrypted
|
'SCRAM-SHA-256' => 1,
|
||||||
|
'SCRAM-SHA-1' => 1,
|
||||||
|
// if $encrypted:
|
||||||
'CRAM-MD5' => $aCredentials['UseAuthCramMd5IfSupported'],
|
'CRAM-MD5' => $aCredentials['UseAuthCramMd5IfSupported'],
|
||||||
'PLAIN' => $aCredentials['UseAuthPlainIfSupported'],
|
'PLAIN' => $aCredentials['UseAuthPlainIfSupported'],
|
||||||
'OAUTHBEARER' => $aCredentials['UseAuthOAuth2IfSupported'],
|
'OAUTHBEARER' => $aCredentials['UseAuthOAuth2IfSupported'],
|
||||||
|
|
|
||||||
|
|
@ -364,59 +364,6 @@ class Account
|
||||||
$bResult = $aCredentials['UseAuth'] && $oClient->Login($aCredentials);
|
$bResult = $aCredentials['UseAuth'] && $oClient->Login($aCredentials);
|
||||||
$oPlugins->RunHook("{$client_name}.after-login", array($this, $oClient, $bResult, $aCredentials));
|
$oPlugins->RunHook("{$client_name}.after-login", array($this, $oClient, $bResult, $aCredentials));
|
||||||
return $bResult;
|
return $bResult;
|
||||||
|
|
||||||
/*
|
|
||||||
// $encrypted = !empty(\stream_get_meta_data($oClient->ConnectionResource())['crypto']);
|
|
||||||
$type = $oClient->IsSupported('LOGINDISABLED') ? '' : 'LOGIN'; // RFC3501 6.2.3
|
|
||||||
$types = [
|
|
||||||
// 'SCRAM-SHA-256' => 1, // !$encrypted
|
|
||||||
// 'SCRAM-SHA-1' => 1, // !$encrypted
|
|
||||||
'CRAM-MD5' => $aSmtpCredentials['UseAuthCramMd5IfSupported'],
|
|
||||||
'PLAIN' => $aSmtpCredentials['UseAuthPlainIfSupported'],
|
|
||||||
'OAUTHBEARER' => $aSmtpCredentials['UseAuthOAuth2IfSupported'],
|
|
||||||
'XOAUTH2' => $aSmtpCredentials['UseAuthOAuth2IfSupported'],
|
|
||||||
'LOGIN' => 1,
|
|
||||||
];
|
|
||||||
foreach ($types as $sasl_type => $active) {
|
|
||||||
if ($active && $oClient->IsSupported("AUTH={$sasl_type}") && \SnappyMail\SASL::isSupported($sasl_type)) {
|
|
||||||
$type = $sasl_type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$SASL = \SnappyMail\SASL::factory($type);
|
|
||||||
$SASL->base64 = true;
|
|
||||||
|
|
||||||
// $oClient->Login($SASL);
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
// $encrypted = !empty(\stream_get_meta_data($oClient->ConnectionResource())['crypto']);
|
|
||||||
$type = '';
|
|
||||||
$types = [
|
|
||||||
'SCRAM-SHA-256' => 1, // !$encrypted
|
|
||||||
'SCRAM-SHA-1' => 1, // !$encrypted
|
|
||||||
'CRAM-MD5' => $bUseAuthCramMd5IfSupported,
|
|
||||||
'PLAIN' => $bUseAuthPlainIfSupported,
|
|
||||||
'LOGIN' => 1, // $encrypted
|
|
||||||
'XOAUTH2' => 0
|
|
||||||
];
|
|
||||||
foreach ($types as $sasl_type => $active) {
|
|
||||||
if ($active && $oClient->IsAuthSupported($sasl_type) && \SnappyMail\SASL::isSupported($sasl_type)) {
|
|
||||||
$type = $sasl_type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$type) {
|
|
||||||
\trigger_error("SMTP {$oClient->GetConnectedHost()} no supported AUTH options. Disable login" . ($oClient->IsSupported('STARTTLS') ? ' or try with STARTTLS' : ''));
|
|
||||||
$oClient->writeLogException(
|
|
||||||
new \MailSo\Smtp\Exceptions\LoginBadMethodException,
|
|
||||||
\MailSo\Log\Enumerations\Type::NOTICE, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$SASL = \SnappyMail\SASL::factory($type);
|
|
||||||
$SASL->base64 = true;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue