This commit is contained in:
the-djmaze 2023-03-21 18:55:38 +01:00
parent a702a45086
commit 7105e23781
31 changed files with 110 additions and 54 deletions

View file

@ -57,6 +57,7 @@ const
smtpShortLogin: false,
smtpUseAuth: true,
smtpSetSender: false,
smtpAuthPlainLine: false,
smtpUsePhpMail: false,
// SSL
smtpSslVerify_peer: false,
@ -106,6 +107,7 @@ const
allow_self_signed: !!oDomain.smtpSslAllow_self_signed()
},
setSender: !!oDomain.smtpSetSender(),
authPlainLine: !!oDomain.smtpAuthPlainLine(),
useAuth: !!oDomain.smtpUseAuth(),
usePhpMail: !!oDomain.smtpUsePhpMail()
},

View file

@ -24,6 +24,8 @@ class Settings extends \MailSo\Net\ConnectSettings
public bool
$setSender = false,
$usePhpMail = false,
// https://github.com/the-djmaze/snappymail/issues/1038
$authPlainLine = false,
$viewErrors = false;
public string $Ehlo;
@ -41,6 +43,7 @@ class Settings extends \MailSo\Net\ConnectSettings
$object->useAuth = !empty($aSettings['useAuth']);
$object->setSender = !empty($aSettings['setSender']);
$object->usePhpMail = !empty($aSettings['usePhpMail']);
$object->authPlainLine = !empty($aSettings['authPlainLine']);
// $object->viewErrors = !empty($aSettings['viewErrors']);
return $object;
}
@ -54,7 +57,8 @@ class Settings extends \MailSo\Net\ConnectSettings
// '@Object' => 'Object/SmtpSettings',
'useAuth' => $this->useAuth,
'setSender' => $this->setSender,
'usePhpMail' => $this->usePhpMail
'usePhpMail' => $this->usePhpMail,
'authPlainLine' => $this->authPlainLine
// 'viewErrors' => $this->viewErrors
]
);

View file

@ -133,60 +133,76 @@ class SmtpClient extends \MailSo\Net\NetClient
$this->writeLogException(new \MailSo\Smtp\Exceptions\LoginBadMethodException);
}
$SASL = \SnappyMail\SASL::factory($type);
$SASL->base64 = true;
// Start authentication
try
{
$sResult = $this->sendRequestWithCheck('AUTH', 334, $type);
}
catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException)
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\LoginBadMethodException($oException->GetResponses(), $oException->getMessage(), 0, $oException)
);
}
try
{
if (\str_starts_with($type, 'SCRAM-')) {
// RFC 5802
$sResult = $this->sendRequestWithCheck($SASL->authenticate($sLogin, $sPassword, $sResult), 234, '');
$sChallenge = $SASL->challenge($sResult);
$this->oLogger && $this->oLogger->AddSecret($sChallenge);
$SASL->verify($this->sendRequestWithCheck($sChallenge, 235, '', true));
} else switch ($type) {
// RFC 4616
case 'PLAIN':
case 'XOAUTH2':
case 'OAUTHBEARER':
$sAuth = $SASL->authenticate($sLogin, $sPassword);
$this->oLogger && $this->oLogger->AddSecret($sAuth);
$this->sendRequestWithCheck($sAuth, 235, '', true);
break;
case 'LOGIN':
$sResult = $this->sendRequestWithCheck($SASL->authenticate($sLogin, $sPassword, $sResult), 334, '');
$sPassword = $SASL->challenge($sResult);
$this->oLogger && $this->oLogger->AddSecret($sPassword);
$this->sendRequestWithCheck($sPassword, 235, '', true);
break;
// RFC 2195
case 'CRAM-MD5':
if (empty($sResult)) {
$this->writeLogException(new \MailSo\Smtp\Exceptions\NegativeResponseException);
}
$this->sendRequestWithCheck($SASL->authenticate($sLogin, $sPassword, $sResult), 235, '', true);
break;
if ($this->Settings->authPlainLine) {
// https://github.com/the-djmaze/snappymail/issues/1038
$SASL = \SnappyMail\SASL::factory('PLAIN');
$SASL->base64 = true;
try
{
$sResult = $this->sendRequestWithCheck('AUTH', 235, 'PLAIN ' . $SASL->authenticate($sLogin, $sPassword));
}
catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException)
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\LoginBadCredentialsException($oException->GetResponses(), $oException->getMessage(), 0, $oException)
);
}
} else {
// Start authentication
$SASL = \SnappyMail\SASL::factory($type);
$SASL->base64 = true;
try
{
$sResult = $this->sendRequestWithCheck('AUTH', 334, $type);
}
catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException)
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\LoginBadMethodException($oException->GetResponses(), $oException->getMessage(), 0, $oException)
);
}
try
{
if (\str_starts_with($type, 'SCRAM-')) {
// RFC 5802
$sResult = $this->sendRequestWithCheck($SASL->authenticate($sLogin, $sPassword, $sResult), 234, '');
$sChallenge = $SASL->challenge($sResult);
$this->oLogger && $this->oLogger->AddSecret($sChallenge);
$SASL->verify($this->sendRequestWithCheck($sChallenge, 235, '', true));
} else switch ($type) {
// RFC 4616
case 'PLAIN':
case 'XOAUTH2':
case 'OAUTHBEARER':
$sAuth = $SASL->authenticate($sLogin, $sPassword);
$this->oLogger && $this->oLogger->AddSecret($sAuth);
$this->sendRequestWithCheck($sAuth, 235, '', true);
break;
case 'LOGIN':
$sResult = $this->sendRequestWithCheck($SASL->authenticate($sLogin, $sPassword, $sResult), 334, '');
$sPassword = $SASL->challenge($sResult);
$this->oLogger && $this->oLogger->AddSecret($sPassword);
$this->sendRequestWithCheck($sPassword, 235, '', true);
break;
// RFC 2195
case 'CRAM-MD5':
if (empty($sResult)) {
$this->writeLogException(new \MailSo\Smtp\Exceptions\NegativeResponseException);
}
$this->sendRequestWithCheck($SASL->authenticate($sLogin, $sPassword, $sResult), 235, '', true);
break;
}
}
catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException)
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\LoginBadCredentialsException($oException->GetResponses(), $oException->getMessage(), 0, $oException)
);
}
}
catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException)
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\LoginBadCredentialsException($oException->GetResponses(), $oException->getMessage(), 0, $oException)
);
}
$this->bIsLoggined = true;

View file

@ -244,6 +244,7 @@ class Domain implements \JsonSerializable
$oDomain->SMTP->shortLogin = !empty($aDomain['smtpShortLogin']);
$oDomain->SMTP->useAuth = !empty($aDomain['smtpAuth']);
$oDomain->SMTP->setSender = !empty($aDomain['smtpSetSender']);
$oDomain->SMTP->authPlainLine = !empty($aDomain['smtpAuthPlainLine']);
$oDomain->SMTP->usePhpMail = !empty($aDomain['smtpPhpMail']);
$oDomain->whiteList = (string) $aDomain['whiteList'];

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Používat krátký login",
"LABEL_USE_AUTH": "Používat autorizaci",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Používat php mail() funkci",
"BUTTON_WHITE_LIST": "White List",
"BUTTON_SIEVE_CONFIGURATION": "SIEVE konfigurace",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Brug kort log ind",
"LABEL_USE_AUTH": "Brug godkendelse",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Brug php mail()",
"BUTTON_WHITE_LIST": "Whitelist",
"BUTTON_SIEVE_CONFIGURATION": "Sieve opsætning",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Kurze Benutzernamen verwenden",
"LABEL_USE_AUTH": "Authentifizierung verwenden",
"LABEL_SET_SENDER": "Verwenden Sie die Anmeldung als Absender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "PHPs mail()-Funktion verwenden",
"BUTTON_WHITE_LIST": "Whitelist",
"BUTTON_SIEVE_CONFIGURATION": "Sieve-Konfiguration",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Use short login",
"LABEL_USE_AUTH": "Use authentication",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Use php mail() function",
"BUTTON_WHITE_LIST": "White List",
"BUTTON_SIEVE_CONFIGURATION": "Sieve configuration",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Inicio de Sesión corto",
"LABEL_USE_AUTH": "Usar autenticación",
"LABEL_SET_SENDER": "Usar inicio de sesión como remitente",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Utilizar la función mail() de PHP",
"BUTTON_WHITE_LIST": "Lista blanca",
"BUTTON_SIEVE_CONFIGURATION": "Configuraciones de Filtro",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Erabili login motza",
"LABEL_USE_AUTH": "Erabili autentikazioa",
"LABEL_SET_SENDER": "Erabili logina bidaltzaile bezala",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Erabili php mail() funtzioa",
"BUTTON_WHITE_LIST": "Zerrenda Zuria",
"BUTTON_SIEVE_CONFIGURATION": "Sieve ezarpenak",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "استفاده از ورود کوتاه بدون دامنه",
"LABEL_USE_AUTH": "استفاده از احراز هویت",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "استفاده از تابع mail() زبان PHP",
"BUTTON_WHITE_LIST": "لیست سفید",
"BUTTON_SIEVE_CONFIGURATION": "پیکربندی Sieve",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Käytä lyhyttä kirjautumista",
"LABEL_USE_AUTH": "Käytä tunnistautumista",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Käytä php mail() funktiota",
"BUTTON_WHITE_LIST": "Sallitut Lista",
"BUTTON_SIEVE_CONFIGURATION": "Sieve asetukset",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Utiliser l'identifiant court",
"LABEL_USE_AUTH": "Utiliser l'authentification",
"LABEL_SET_SENDER": "Utiliser la connexion en tant qu'expéditeur",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Utiliser la fonction mail() de php",
"BUTTON_WHITE_LIST": "Liste Blanche",
"BUTTON_SIEVE_CONFIGURATION": "Configuration sieve",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Rövid felhasználónév használata",
"LABEL_USE_AUTH": "Hitelesítés használata",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "A PHP mail() funkció használata",
"BUTTON_WHITE_LIST": "Fehér lista",
"BUTTON_SIEVE_CONFIGURATION": "SIEVE beállítás",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Gunakan login singkat",
"LABEL_USE_AUTH": "Gunakan otentikasi",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Gunakan fungsi mail() PHP",
"BUTTON_WHITE_LIST": "Daftar Putih",
"BUTTON_SIEVE_CONFIGURATION": "Konfigurasi Sieve",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Use short login",
"LABEL_USE_AUTH": "Use authentication",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Use php mail() function",
"BUTTON_WHITE_LIST": "White List",
"BUTTON_SIEVE_CONFIGURATION": "Sieve configuration",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "短いログイン名を使う",
"LABEL_USE_AUTH": "認証を使用する",
"LABEL_SET_SENDER": "ログイン名を送信者として使う",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "PHPのmail()関数を使用する",
"BUTTON_WHITE_LIST": "ホワイトリスト",
"BUTTON_SIEVE_CONFIGURATION": "SIEVE設定",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Naudoti trumpą prisijungimo vardą",
"LABEL_USE_AUTH": "Naudoti autentifikavimą ",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Naudoti php mail() funkciją",
"BUTTON_WHITE_LIST": "Baltas sąrašas",
"BUTTON_SIEVE_CONFIGURATION": "Sieve konfiguracija",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Bruk forkortet brukernavn",
"LABEL_USE_AUTH": "Bruk autentisering",
"LABEL_SET_SENDER": "Bruk pålogging som avsender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Bruk php-funksjonen «mail()»",
"BUTTON_WHITE_LIST": "Hvitliste",
"BUTTON_SIEVE_CONFIGURATION": "Sieve-oppsett",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Gebruik verkorte login",
"LABEL_USE_AUTH": "Gebruik authenticatie",
"LABEL_SET_SENDER": "Gebruik login als verzender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Gebruik php mail() functie",
"BUTTON_WHITE_LIST": "Witte lijst",
"BUTTON_SIEVE_CONFIGURATION": "Sieve configuratie",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Użyj krótkiego loginu",
"LABEL_USE_AUTH": "Użyj autoryzacji",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Użyj funkcji php 'mail()'",
"BUTTON_WHITE_LIST": "Biała lista",
"BUTTON_SIEVE_CONFIGURATION": "Konfiguracja sieve",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Usar login curto",
"LABEL_USE_AUTH": "Usar autenticação",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Usar função php mail()",
"BUTTON_WHITE_LIST": "Lista branca",
"BUTTON_SIEVE_CONFIGURATION": "Configurações Sieve",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Usar nome de utilizador curto",
"LABEL_USE_AUTH": "Usar autenticação",
"LABEL_SET_SENDER": "Usar nome de utilizador como remetente",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Usar a função php mail()",
"BUTTON_WHITE_LIST": "Lista Branca",
"BUTTON_SIEVE_CONFIGURATION": "Configuração SIEVE",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Usar nome de utilizador curto",
"LABEL_USE_AUTH": "Usar autenticação",
"LABEL_SET_SENDER": "Usar nome de utilizador como remetente",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Usar a função php mail()",
"BUTTON_WHITE_LIST": "Lista Branca",
"BUTTON_SIEVE_CONFIGURATION": "Configuração SIEVE",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Использовать короткий логин",
"LABEL_USE_AUTH": "Использовать аутентификацию",
"LABEL_SET_SENDER": "Использовать логин в качестве отправителя",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Использовать mail() функцию",
"BUTTON_WHITE_LIST": "Белый список",
"BUTTON_SIEVE_CONFIGURATION": "Настройки Sieve",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Použiť skrátené prihlásenie",
"LABEL_USE_AUTH": "Použiť overenie",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Použiť php mail() funkciu",
"BUTTON_WHITE_LIST": "Zoznam povolených",
"BUTTON_SIEVE_CONFIGURATION": "Nastavenia Sieve",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Uporaba uporabniškega imena brez domene",
"LABEL_USE_AUTH": "Uporaba overjanja",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Uporaba php mail() funkcije",
"BUTTON_WHITE_LIST": "Dodaj na belo listo",
"BUTTON_SIEVE_CONFIGURATION": "Konfiguriraj Sieve",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Använda korta inloggning",
"LABEL_USE_AUTH": "Använd autentisering",
"LABEL_SET_SENDER": "Use login as sender",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Använd php mail() funktionen",
"BUTTON_WHITE_LIST": "Vitlista",
"BUTTON_SIEVE_CONFIGURATION": "sil-konfiguration",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "Dùng đăng nhập ngắn",
"LABEL_USE_AUTH": "Dùng xác minh",
"LABEL_SET_SENDER": "Dùng tên đăng nhập là email người dùng",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "Dùng phương trình php mail()",
"BUTTON_WHITE_LIST": "Danh sách trắng",
"BUTTON_SIEVE_CONFIGURATION": "Thiết lập Sieve",

View file

@ -135,6 +135,7 @@
"LABEL_USE_SHORT_LOGIN": "使用短用户名登录",
"LABEL_USE_AUTH": "使用认证",
"LABEL_SET_SENDER": "使用登录名作为发件人",
"LABEL_AUTH_PLAIN_LINE": "Force single command AUTH PLAIN login",
"LABEL_USE_PHP_MAIL": "使用 php mail() 函数",
"BUTTON_WHITE_LIST": "白名单",
"BUTTON_SIEVE_CONFIGURATION": "筛选设置",

View file

@ -193,6 +193,13 @@
value: smtpSetSender
}
}"></div>
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'POPUPS_DOMAIN/LABEL_AUTH_PLAIN_LINE',
value: smtpAuthPlainLine
}
}"></div>
<div style="display: inline-block;" data-bind="component: {
name: 'Checkbox',
params: {