diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php index 5d03b003e..3e524c1d8 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php @@ -119,13 +119,17 @@ class ImapClient extends \MailSo\Net\NetClient $this->sLogginedUser = $sLogin; - $type = $this->IsSupported('LOGINDISABLED') ? '' : 'LOGIN'; // RFC3501 6.2.3 + $type = ''; foreach ($oSettings->SASLMechanisms as $sasl_type) { if ($this->IsSupported("AUTH={$sasl_type}") && \SnappyMail\SASL::isSupported($sasl_type)) { $type = $sasl_type; break; } } + // RFC3501 6.2.3 + if ('LOGIN' === $type && $this->IsSupported('LOGINDISABLED')) { + $type = ''; + } if (!$type) { if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) { $this->StartTLS(); diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Net/ConnectSettings.php b/snappymail/v/0.0.0/app/libraries/MailSo/Net/ConnectSettings.php index 4b5f06d19..5fbf28fdf 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Net/ConnectSettings.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Net/ConnectSettings.php @@ -35,7 +35,16 @@ class ConnectSettings implements \JsonSerializable // Authentication settings use by all child classes public bool $useAuth = true; public bool $shortLogin = false; - public array $SASLMechanisms = []; + public array $SASLMechanisms = [ + // https://github.com/the-djmaze/snappymail/issues/182 + 'SCRAM-SHA3-512', + 'SCRAM-SHA-512', + 'SCRAM-SHA-256', + 'SCRAM-SHA-1', +// 'CRAM-MD5', + 'PLAIN', + 'LOGIN' + ]; public string $Login = ''; public string $Password = ''; public string $ProxyAuthUser = ''; @@ -62,6 +71,9 @@ class ConnectSettings implements \JsonSerializable } $object->shortLogin = !empty($aSettings['shortLogin']); $object->ssl = SSLContext::fromArray($aSettings['ssl'] ?? []); + if (isset($aSettings['sasl'])) { + $object->SASLMechanisms = $aSettings['sasl']; + } return $object; } @@ -75,6 +87,7 @@ class ConnectSettings implements \JsonSerializable 'type' => $this->type, 'timeout' => $this->timeout, 'shortLogin' => $this->shortLogin, + 'sasl' => $this->SASLMechanisms, 'ssl' => $this->ssl ); } diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Sieve/SieveClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Sieve/SieveClient.php index 5a43e8738..9d57bad9a 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Sieve/SieveClient.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Sieve/SieveClient.php @@ -113,14 +113,12 @@ class SieveClient extends \MailSo\Net\NetClient } $type = ''; - \array_push($oSettings->SASLMechanisms, 'PLAIN', 'LOGIN'); foreach ($oSettings->SASLMechanisms as $sasl_type) { if ($this->IsAuthSupported($sasl_type) && \SnappyMail\SASL::isSupported($sasl_type)) { $type = $sasl_type; break; } } - if (!$type) { if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) { $this->StartTLS(); diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php index ed1af76c2..351db3b20 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php @@ -143,14 +143,12 @@ class SmtpClient extends \MailSo\Net\NetClient $sPassword = $oSettings->Password; $type = ''; - $oSettings->SASLMechanisms[] = 'LOGIN'; foreach ($oSettings->SASLMechanisms as $sasl_type) { if ($this->IsAuthSupported($sasl_type) && \SnappyMail\SASL::isSupported($sasl_type)) { $type = $sasl_type; break; } } - if (!$type) { if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) { $this->StartTLS(); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php index bd7151c3f..6cda116c3 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -382,9 +382,6 @@ Enables caching in the system'), 'smtp_show_server_errors' => array(false), 'sieve_auth_plain_initial' => array(true), 'sieve_allow_fileinto_inbox' => array(false), - 'sasl_allow_plain' => array(true), - 'sasl_allow_scram_sha' => array(false), - 'sasl_allow_cram_md5' => array(false), 'mail_func_clear_headers' => array(true), 'mail_func_additional_parameters' => array(false), 'folders_spec_limit' => array(50), diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Domain.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Domain.php index 386d26ca9..c90e98e4d 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Domain.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Domain.php @@ -200,34 +200,17 @@ class Domain implements \JsonSerializable public function ImapSettings() : \MailSo\Imap\Settings { - return static::mergeGlobalSettings($this->IMAP); + return $this->IMAP; } public function SmtpSettings() : \MailSo\Smtp\Settings { - return static::mergeGlobalSettings($this->SMTP); + return $this->SMTP; } public function SieveSettings() : \MailSo\Sieve\Settings { - return static::mergeGlobalSettings($this->Sieve); - } - - private static function mergeGlobalSettings(\MailSo\Net\ConnectSettings $oSettings) : \MailSo\Net\ConnectSettings - { - $oConfig = \RainLoop\API::Config(); - if ($oConfig->Get('labs', 'sasl_allow_scram_sha', false)) { - // https://github.com/the-djmaze/snappymail/issues/182 - \array_push($oSettings->SASLMechanisms, 'SCRAM-SHA3-512', 'SCRAM-SHA-512', 'SCRAM-SHA-256', 'SCRAM-SHA-1'); - } - if ($oConfig->Get('labs', 'sasl_allow_cram_md5', false)) { - $oSettings->SASLMechanisms[] = 'CRAM-MD5'; - } - if ($oConfig->Get('labs', 'sasl_allow_plain', true)) { - $oSettings->SASLMechanisms[] = 'PLAIN'; - } - - return $oSettings; + return $this->Sieve; } /**