From 2feee6d1ddfb6d014a05d05e2191b6d0b254a39f Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Mon, 17 Nov 2014 22:38:45 +0400 Subject: [PATCH] Fixed domain popup saving --- dev/View/Popup/Domain.js | 4 +- rainloop/v/0.0.0/app/src/RainLoop/Actions.php | 54 +++++++++++-------- .../v/0.0.0/app/src/RainLoop/Model/Domain.php | 7 ++- .../Views/Admin/AdminSettingsBranding.html | 2 +- 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/dev/View/Popup/Domain.js b/dev/View/Popup/Domain.js index 3649ebfaa..0599f6108 100644 --- a/dev/View/Popup/Domain.js +++ b/dev/View/Popup/Domain.js @@ -81,11 +81,11 @@ }, this); this.domainIsComputed = ko.computed(function () { + var bPhpMail = this.smtpPhpMail(); return '' !== this.name() && '' !== this.imapServer() && '' !== this.imapPort() && - '' !== this.smtpServer() && - '' !== this.smtpPort(); + (('' !== this.smtpServer() && '' !== this.smtpPort()) || bPhpMail); }, this); this.canBeTested = ko.computed(function () { diff --git a/rainloop/v/0.0.0/app/src/RainLoop/Actions.php b/rainloop/v/0.0.0/app/src/RainLoop/Actions.php index c736b65ac..2278c8f92 100644 --- a/rainloop/v/0.0.0/app/src/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/src/RainLoop/Actions.php @@ -2989,32 +2989,44 @@ class Actions $sImapErrorDesc = $oException->getMessage(); } - try + if ($oDomain->OutUsePhpMail()) { - $oSmtpClient = \MailSo\Smtp\SmtpClient::NewInstance()->SetLogger($this->Logger()); - $oSmtpClient->SetTimeOuts(5); - - $iTime = \microtime(true); - $oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(), '127.0.0.1', - $oDomain->OutSecure(), !!$this->Config()->Get('ssl', 'verify_certificate')); - - $iSmtpTime = \microtime(true) - $iTime; - $oSmtpClient->Disconnect(); - $bSmtpResult = true; - } - catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException) - { - $this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR); - $sSmtpErrorDesc = $oException->getSocketMessage(); - if (empty($sSmtpErrorDesc)) + $bSmtpResult = \MailSo\Base\Utils::FunctionExistsAndEnabled('mail'); + $bSmtpResult = false; + if (!$bSmtpResult) { - $sSmtpErrorDesc = $oException->getMessage(); + $sSmtpErrorDesc = 'PHP: mail() function is undefined'; } } - catch (\Exception $oException) + else { - $this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR); - $sSmtpErrorDesc = $oException->getMessage(); + try + { + $oSmtpClient = \MailSo\Smtp\SmtpClient::NewInstance()->SetLogger($this->Logger()); + $oSmtpClient->SetTimeOuts(5); + + $iTime = \microtime(true); + $oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(), '127.0.0.1', + $oDomain->OutSecure(), !!$this->Config()->Get('ssl', 'verify_certificate')); + + $iSmtpTime = \microtime(true) - $iTime; + $oSmtpClient->Disconnect(); + $bSmtpResult = true; + } + catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException) + { + $this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR); + $sSmtpErrorDesc = $oException->getSocketMessage(); + if (empty($sSmtpErrorDesc)) + { + $sSmtpErrorDesc = $oException->getMessage(); + } + } + catch (\Exception $oException) + { + $this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR); + $sSmtpErrorDesc = $oException->getMessage(); + } } } diff --git a/rainloop/v/0.0.0/app/src/RainLoop/Model/Domain.php b/rainloop/v/0.0.0/app/src/RainLoop/Model/Domain.php index 6cde5b158..a2c62b047 100644 --- a/rainloop/v/0.0.0/app/src/RainLoop/Model/Domain.php +++ b/rainloop/v/0.0.0/app/src/RainLoop/Model/Domain.php @@ -136,16 +136,15 @@ class Domain { $oDomain = null; - if (0 < \strlen($sName) && \is_array($aDomain) && 0 < \strlen($aDomain['imap_host']) && 0 < \strlen($aDomain['imap_port']) && - 0 < \strlen($aDomain['smtp_host']) && 0 < \strlen($aDomain['smtp_port'])) + if (0 < \strlen($sName) && \is_array($aDomain) && 0 < \strlen($aDomain['imap_host']) && 0 < \strlen($aDomain['imap_port'])) { $sIncHost = (string) $aDomain['imap_host']; $iIncPort = (int) $aDomain['imap_port']; $iIncSecure = self::StrConnectionSecurityTypeToCons( !empty($aDomain['imap_secure']) ? $aDomain['imap_secure'] : ''); - $sOutHost = (string) $aDomain['smtp_host']; - $iOutPort = (int) $aDomain['smtp_port']; + $sOutHost = empty($aDomain['smtp_host']) ? '' : (string) $aDomain['smtp_host']; + $iOutPort = empty($aDomain['smtp_port']) ? 25 : (int) $aDomain['smtp_port']; $iOutSecure = self::StrConnectionSecurityTypeToCons( !empty($aDomain['smtp_secure']) ? $aDomain['smtp_secure'] : ''); diff --git a/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsBranding.html b/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsBranding.html index 05d554c4d..09868d515 100644 --- a/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsBranding.html +++ b/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsBranding.html @@ -83,7 +83,7 @@ name: 'Checkbox', params: { enable: capa, - label: 'Show "Powered by RainLoop" link (White Labeling)', + label: 'Show "Powered by RainLoop" link', value: loginPowered } }">