mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Put domain capabilities in ?admin domain test response
This commit is contained in:
parent
0dfcc52728
commit
cb2f641378
3 changed files with 38 additions and 18 deletions
|
|
@ -213,12 +213,13 @@ class SieveClient extends \MailSo\Net\NetClient
|
||||||
* @throws \MailSo\Net\Exceptions\*
|
* @throws \MailSo\Net\Exceptions\*
|
||||||
* @throws \MailSo\Sieve\Exceptions\*
|
* @throws \MailSo\Sieve\Exceptions\*
|
||||||
*/
|
*/
|
||||||
public function Capability() : array
|
public function Capability(bool $force = false) : array
|
||||||
{
|
{
|
||||||
$this->sendRequest('CAPABILITY');
|
if (!$this->aCapa || $force) {
|
||||||
$aResponse = $this->parseResponse();
|
$this->sendRequest('CAPABILITY');
|
||||||
$this->parseStartupResponse($aResponse);
|
$aResponse = $this->parseResponse();
|
||||||
|
$this->parseStartupResponse($aResponse);
|
||||||
|
}
|
||||||
return $this->aCapa;
|
return $this->aCapa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -348,6 +349,7 @@ class SieveClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
private function parseStartupResponse(array $aResponse) : void
|
private function parseStartupResponse(array $aResponse) : void
|
||||||
{
|
{
|
||||||
|
$this->aCapa = [];
|
||||||
foreach ($aResponse as $sLine) {
|
foreach ($aResponse as $sLine) {
|
||||||
$aTokens = $this->parseLine($sLine);
|
$aTokens = $this->parseLine($sLine);
|
||||||
if (empty($aTokens[0]) || \in_array(\substr($sLine, 0, 2), array('OK', 'NO'))) {
|
if (empty($aTokens[0]) || \in_array(\substr($sLine, 0, 2), array('OK', 'NO'))) {
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,11 @@ class SmtpClient extends \MailSo\Net\NetClient
|
||||||
|
|
||||||
private array $aResults = array();
|
private array $aResults = array();
|
||||||
|
|
||||||
|
public function Capability() : array
|
||||||
|
{
|
||||||
|
return $this->aCapa;
|
||||||
|
}
|
||||||
|
|
||||||
public function hasCapability(string $sCapa) : bool
|
public function hasCapability(string $sCapa) : bool
|
||||||
{
|
{
|
||||||
return \in_array(\strtoupper($sCapa), $this->aCapa);
|
return \in_array(\strtoupper($sCapa), $this->aCapa);
|
||||||
|
|
@ -478,6 +483,7 @@ class SmtpClient extends \MailSo\Net\NetClient
|
||||||
250-DSN\r\n
|
250-DSN\r\n
|
||||||
250 SMTPUTF8\r\n
|
250 SMTPUTF8\r\n
|
||||||
*/
|
*/
|
||||||
|
$this->aCapa = [];
|
||||||
foreach ($this->aResults as $sLine) {
|
foreach ($this->aResults as $sLine) {
|
||||||
$aMatch = array();
|
$aMatch = array();
|
||||||
if (\preg_match('/[\d]+[ \-](.+)$/', $sLine, $aMatch) && isset($aMatch[1]) && \strlen($aMatch[1])) {
|
if (\preg_match('/[\d]+[ \-](.+)$/', $sLine, $aMatch) && isset($aMatch[1]) && \strlen($aMatch[1])) {
|
||||||
|
|
@ -510,7 +516,7 @@ class SmtpClient extends \MailSo\Net\NetClient
|
||||||
$this->sendRequestWithCheck('HELO', 250, $sHost);
|
$this->sendRequestWithCheck('HELO', 250, $sHost);
|
||||||
$this->aAuthTypes = array();
|
$this->aAuthTypes = array();
|
||||||
$this->iSizeCapaValue = 0;
|
$this->iSizeCapaValue = 0;
|
||||||
$this->aCapa = array();
|
$this->aCapa = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -78,11 +78,11 @@ trait AdminDomains
|
||||||
{
|
{
|
||||||
$this->IsAdminLoggined();
|
$this->IsAdminLoggined();
|
||||||
|
|
||||||
$bImapResult = false;
|
$mImapResult = false;
|
||||||
$sImapErrorDesc = '';
|
$sImapErrorDesc = '';
|
||||||
$bSmtpResult = false;
|
$mSmtpResult = false;
|
||||||
$sSmtpErrorDesc = '';
|
$sSmtpErrorDesc = '';
|
||||||
$bSieveResult = false;
|
$mSieveResult = false;
|
||||||
$sSieveErrorDesc = '';
|
$sSieveErrorDesc = '';
|
||||||
|
|
||||||
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this, 'test.example.com');
|
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this, 'test.example.com');
|
||||||
|
|
@ -96,15 +96,18 @@ trait AdminDomains
|
||||||
|
|
||||||
$oSettings = $oDomain->ImapSettings();
|
$oSettings = $oDomain->ImapSettings();
|
||||||
$oImapClient->Connect($oSettings);
|
$oImapClient->Connect($oSettings);
|
||||||
|
$mImapResult = [
|
||||||
|
'connectCapa' => $oImapClient->Capability()
|
||||||
|
];
|
||||||
|
|
||||||
if (!empty($aAuth['user'])) {
|
if (!empty($aAuth['user'])) {
|
||||||
$oSettings->Login = $aAuth['user'];
|
$oSettings->Login = $aAuth['user'];
|
||||||
$oSettings->Password = $aAuth['pass'];
|
$oSettings->Password = $aAuth['pass'];
|
||||||
$oImapClient->Login($oSettings);
|
$oImapClient->Login($oSettings);
|
||||||
|
$mImapResult['authCapa'] = $oImapClient->Capability();
|
||||||
}
|
}
|
||||||
|
|
||||||
$oImapClient->Disconnect();
|
$oImapClient->Disconnect();
|
||||||
$bImapResult = true;
|
|
||||||
}
|
}
|
||||||
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
||||||
{
|
{
|
||||||
|
|
@ -121,8 +124,8 @@ trait AdminDomains
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oDomain->OutUsePhpMail()) {
|
if ($oDomain->OutUsePhpMail()) {
|
||||||
$bSmtpResult = \MailSo\Base\Utils::FunctionCallable('mail');
|
$mSmtpResult = \MailSo\Base\Utils::FunctionCallable('mail');
|
||||||
if (!$bSmtpResult) {
|
if (!$mSmtpResult) {
|
||||||
$sSmtpErrorDesc = 'PHP: mail() function is undefined';
|
$sSmtpErrorDesc = 'PHP: mail() function is undefined';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -134,15 +137,18 @@ trait AdminDomains
|
||||||
$oSettings = $oDomain->SmtpSettings();
|
$oSettings = $oDomain->SmtpSettings();
|
||||||
$oSettings->Ehlo = \MailSo\Smtp\SmtpClient::EhloHelper();
|
$oSettings->Ehlo = \MailSo\Smtp\SmtpClient::EhloHelper();
|
||||||
$oSmtpClient->Connect($oSettings);
|
$oSmtpClient->Connect($oSettings);
|
||||||
|
$mSmtpResult = [
|
||||||
|
'connectCapa' => $oSmtpClient->Capability()
|
||||||
|
];
|
||||||
|
|
||||||
if (!empty($aAuth['user'])) {
|
if (!empty($aAuth['user'])) {
|
||||||
$oSettings->Login = $aAuth['user'];
|
$oSettings->Login = $aAuth['user'];
|
||||||
$oSettings->Password = $aAuth['pass'];
|
$oSettings->Password = $aAuth['pass'];
|
||||||
$oSmtpClient->Login($oSettings);
|
$oSmtpClient->Login($oSettings);
|
||||||
|
$mSmtpResult['authCapa'] = $oSmtpClient->Capability();
|
||||||
}
|
}
|
||||||
|
|
||||||
$oSmtpClient->Disconnect();
|
$oSmtpClient->Disconnect();
|
||||||
$bSmtpResult = true;
|
|
||||||
}
|
}
|
||||||
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
||||||
{
|
{
|
||||||
|
|
@ -167,15 +173,18 @@ trait AdminDomains
|
||||||
|
|
||||||
$oSettings = $oDomain->SieveSettings();
|
$oSettings = $oDomain->SieveSettings();
|
||||||
$oSieveClient->Connect($oSettings);
|
$oSieveClient->Connect($oSettings);
|
||||||
|
$mSieveResult = [
|
||||||
|
'connectCapa' => $oSieveClient->Capability()
|
||||||
|
];
|
||||||
|
|
||||||
if (!empty($aAuth['user'])) {
|
if (!empty($aAuth['user'])) {
|
||||||
$oSettings->Login = $aAuth['user'];
|
$oSettings->Login = $aAuth['user'];
|
||||||
$oSettings->Password = $aAuth['pass'];
|
$oSettings->Password = $aAuth['pass'];
|
||||||
$oSieveClient->Login($oSettings);
|
$oSieveClient->Login($oSettings);
|
||||||
|
$mSieveResult['authCapa'] = $oSieveClient->Capability();
|
||||||
}
|
}
|
||||||
|
|
||||||
$oSieveClient->Disconnect();
|
$oSieveClient->Disconnect();
|
||||||
$bSieveResult = true;
|
|
||||||
}
|
}
|
||||||
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
||||||
{
|
{
|
||||||
|
|
@ -191,14 +200,17 @@ trait AdminDomains
|
||||||
$sSieveErrorDesc = $oException->getMessage();
|
$sSieveErrorDesc = $oException->getMessage();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$bSieveResult = true;
|
$mSieveResult = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->DefaultResponse(array(
|
return $this->DefaultResponse(array(
|
||||||
'Imap' => $bImapResult ? true : $sImapErrorDesc,
|
'Imap' => $mImapResult ? true : $sImapErrorDesc,
|
||||||
'Smtp' => $bSmtpResult ? true : $sSmtpErrorDesc,
|
'Smtp' => $mSmtpResult ? true : $sSmtpErrorDesc,
|
||||||
'Sieve' => $bSieveResult ? true : $sSieveErrorDesc
|
'Sieve' => $mSieveResult ? true : $sSieveErrorDesc,
|
||||||
|
'ImapResult' => $mImapResult,
|
||||||
|
'SmtpResult' => $mSmtpResult,
|
||||||
|
'SieveResult' => $mSieveResult
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue