From 0f7ebc084afa259e11c5ab11a81b20a866dcca3e Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Tue, 3 Dec 2013 04:14:54 +0400 Subject: [PATCH] More correct function smtp ehlo definitions. --- .../app/libraries/MailSo/Smtp/SmtpClient.php | 26 +++++++++++++++++++ .../0.0.0/app/libraries/RainLoop/Actions.php | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php index 4618aa178..f204444eb 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php @@ -111,6 +111,32 @@ class SmtpClient extends \MailSo\Net\NetClient return $this->IsAuthSupported('PLAIN') || $this->IsAuthSupported('LOGIN'); } + /** + * @return string + */ + public static function EhloHelper() + { + $sEhloHost = empty($_SERVER['SERVER_NAME']) ? '' : \trim($_SERVER['SERVER_NAME']); + if (empty($sEhloHost)) + { + $sEhloHost = empty($_SERVER['HTTP_HOST']) ? '' : \trim($_SERVER['HTTP_HOST']); + } + + if (empty($sEhloHost)) + { + $sEhloHost = \function_exists('gethostname') ? \gethostname() : 'localhost'; + } + + $sEhloHost = \trim(\preg_replace('/:\d+$/', '', \trim($sEhloHost))); + + if (\preg_match('/^\d+\.\d+\.\d+\.\d+$/', $sEhloHost)) + { + $sEhloHost = '['.$sEhloHost.']'; + } + + return empty($sEhloHost) ? 'localhost' : $sEhloHost; + } + /** * @param string $sServerName * @param int $iPort = 25 diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index e2309b03c..777df3ae2 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -3732,7 +3732,7 @@ class Actions $sFrom = $oFrom instanceof \MailSo\Mime\Email ? $oFrom->GetEmail() : ''; $aSmtpCredentials = array( - 'Ehlo' => \function_exists('gethostname') ? \gethostname() : 'localhost', + 'Ehlo' => \MailSo\Smtp\SmtpClient::EhloHelper(), 'Host' => $oAccount->Domain()->OutHost(), 'Port' => $oAccount->Domain()->OutPort(), 'Secure' => $oAccount->Domain()->OutSecure(),