mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
parent
439ad5596f
commit
21d7e91493
6 changed files with 22 additions and 29 deletions
|
|
@ -119,13 +119,17 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
|
|
||||||
$this->sLogginedUser = $sLogin;
|
$this->sLogginedUser = $sLogin;
|
||||||
|
|
||||||
$type = $this->IsSupported('LOGINDISABLED') ? '' : 'LOGIN'; // RFC3501 6.2.3
|
$type = '';
|
||||||
foreach ($oSettings->SASLMechanisms as $sasl_type) {
|
foreach ($oSettings->SASLMechanisms as $sasl_type) {
|
||||||
if ($this->IsSupported("AUTH={$sasl_type}") && \SnappyMail\SASL::isSupported($sasl_type)) {
|
if ($this->IsSupported("AUTH={$sasl_type}") && \SnappyMail\SASL::isSupported($sasl_type)) {
|
||||||
$type = $sasl_type;
|
$type = $sasl_type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// RFC3501 6.2.3
|
||||||
|
if ('LOGIN' === $type && $this->IsSupported('LOGINDISABLED')) {
|
||||||
|
$type = '';
|
||||||
|
}
|
||||||
if (!$type) {
|
if (!$type) {
|
||||||
if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) {
|
if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) {
|
||||||
$this->StartTLS();
|
$this->StartTLS();
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,16 @@ class ConnectSettings implements \JsonSerializable
|
||||||
// Authentication settings use by all child classes
|
// Authentication settings use by all child classes
|
||||||
public bool $useAuth = true;
|
public bool $useAuth = true;
|
||||||
public bool $shortLogin = false;
|
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 $Login = '';
|
||||||
public string $Password = '';
|
public string $Password = '';
|
||||||
public string $ProxyAuthUser = '';
|
public string $ProxyAuthUser = '';
|
||||||
|
|
@ -62,6 +71,9 @@ class ConnectSettings implements \JsonSerializable
|
||||||
}
|
}
|
||||||
$object->shortLogin = !empty($aSettings['shortLogin']);
|
$object->shortLogin = !empty($aSettings['shortLogin']);
|
||||||
$object->ssl = SSLContext::fromArray($aSettings['ssl'] ?? []);
|
$object->ssl = SSLContext::fromArray($aSettings['ssl'] ?? []);
|
||||||
|
if (isset($aSettings['sasl'])) {
|
||||||
|
$object->SASLMechanisms = $aSettings['sasl'];
|
||||||
|
}
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,6 +87,7 @@ class ConnectSettings implements \JsonSerializable
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'timeout' => $this->timeout,
|
'timeout' => $this->timeout,
|
||||||
'shortLogin' => $this->shortLogin,
|
'shortLogin' => $this->shortLogin,
|
||||||
|
'sasl' => $this->SASLMechanisms,
|
||||||
'ssl' => $this->ssl
|
'ssl' => $this->ssl
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,14 +113,12 @@ class SieveClient extends \MailSo\Net\NetClient
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = '';
|
$type = '';
|
||||||
\array_push($oSettings->SASLMechanisms, 'PLAIN', 'LOGIN');
|
|
||||||
foreach ($oSettings->SASLMechanisms as $sasl_type) {
|
foreach ($oSettings->SASLMechanisms as $sasl_type) {
|
||||||
if ($this->IsAuthSupported($sasl_type) && \SnappyMail\SASL::isSupported($sasl_type)) {
|
if ($this->IsAuthSupported($sasl_type) && \SnappyMail\SASL::isSupported($sasl_type)) {
|
||||||
$type = $sasl_type;
|
$type = $sasl_type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$type) {
|
if (!$type) {
|
||||||
if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) {
|
if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) {
|
||||||
$this->StartTLS();
|
$this->StartTLS();
|
||||||
|
|
|
||||||
|
|
@ -143,14 +143,12 @@ class SmtpClient extends \MailSo\Net\NetClient
|
||||||
$sPassword = $oSettings->Password;
|
$sPassword = $oSettings->Password;
|
||||||
|
|
||||||
$type = '';
|
$type = '';
|
||||||
$oSettings->SASLMechanisms[] = 'LOGIN';
|
|
||||||
foreach ($oSettings->SASLMechanisms as $sasl_type) {
|
foreach ($oSettings->SASLMechanisms as $sasl_type) {
|
||||||
if ($this->IsAuthSupported($sasl_type) && \SnappyMail\SASL::isSupported($sasl_type)) {
|
if ($this->IsAuthSupported($sasl_type) && \SnappyMail\SASL::isSupported($sasl_type)) {
|
||||||
$type = $sasl_type;
|
$type = $sasl_type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$type) {
|
if (!$type) {
|
||||||
if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) {
|
if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) {
|
||||||
$this->StartTLS();
|
$this->StartTLS();
|
||||||
|
|
|
||||||
|
|
@ -382,9 +382,6 @@ Enables caching in the system'),
|
||||||
'smtp_show_server_errors' => array(false),
|
'smtp_show_server_errors' => array(false),
|
||||||
'sieve_auth_plain_initial' => array(true),
|
'sieve_auth_plain_initial' => array(true),
|
||||||
'sieve_allow_fileinto_inbox' => array(false),
|
'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_clear_headers' => array(true),
|
||||||
'mail_func_additional_parameters' => array(false),
|
'mail_func_additional_parameters' => array(false),
|
||||||
'folders_spec_limit' => array(50),
|
'folders_spec_limit' => array(50),
|
||||||
|
|
|
||||||
|
|
@ -200,34 +200,17 @@ class Domain implements \JsonSerializable
|
||||||
|
|
||||||
public function ImapSettings() : \MailSo\Imap\Settings
|
public function ImapSettings() : \MailSo\Imap\Settings
|
||||||
{
|
{
|
||||||
return static::mergeGlobalSettings($this->IMAP);
|
return $this->IMAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SmtpSettings() : \MailSo\Smtp\Settings
|
public function SmtpSettings() : \MailSo\Smtp\Settings
|
||||||
{
|
{
|
||||||
return static::mergeGlobalSettings($this->SMTP);
|
return $this->SMTP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SieveSettings() : \MailSo\Sieve\Settings
|
public function SieveSettings() : \MailSo\Sieve\Settings
|
||||||
{
|
{
|
||||||
return static::mergeGlobalSettings($this->Sieve);
|
return $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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue