SmtpClient->Connect() use $oSettings->Ehlo

This commit is contained in:
the-djmaze 2023-02-15 12:59:49 +01:00
parent 353fdda3e5
commit edcb84b4ae
3 changed files with 11 additions and 9 deletions

View file

@ -72,14 +72,14 @@ class SmtpClient extends \MailSo\Net\NetClient
* @throws \MailSo\Net\Exceptions\* * @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Smtp\Exceptions\* * @throws \MailSo\Smtp\Exceptions\*
*/ */
public function Connect(\MailSo\Net\ConnectSettings $oSettings, string $sEhloHost = '[127.0.0.1]') : void public function Connect(\MailSo\Net\ConnectSettings $oSettings) : void
{ {
parent::Connect($oSettings); parent::Connect($oSettings);
$this->validateResponse(220); $this->validateResponse(220);
$this->ehloOrHelo($sEhloHost); $this->ehloOrHelo($oSettings->Ehlo);
$this->sEhlo = $sEhloHost; $this->sEhlo = $oSettings->Ehlo;
if (ConnectionSecurityType::STARTTLS === $this->Settings->type if (ConnectionSecurityType::STARTTLS === $this->Settings->type
|| (ConnectionSecurityType::AUTO_DETECT === $this->Settings->type && $this->hasCapability('STARTTLS'))) { || (ConnectionSecurityType::AUTO_DETECT === $this->Settings->type && $this->hasCapability('STARTTLS'))) {

View file

@ -132,7 +132,8 @@ trait AdminDomains
$oSmtpClient->SetLogger($this->Logger()); $oSmtpClient->SetLogger($this->Logger());
$oSettings = $oDomain->SmtpSettings(); $oSettings = $oDomain->SmtpSettings();
$oSmtpClient->Connect($oSettings, \MailSo\Smtp\SmtpClient::EhloHelper()); $oSettings->Ehlo = \MailSo\Smtp\SmtpClient::EhloHelper();
$oSmtpClient->Connect($oSettings);
if (!empty($aAuth['user'])) { if (!empty($aAuth['user'])) {
$oSettings->Login = $aAuth['user']; $oSettings->Login = $aAuth['user'];

View file

@ -235,7 +235,7 @@ abstract class Account implements \JsonSerializable
$oPlugins->RunHook('imap.after-connect', array($this, $oImapClient, $oSettings)); $oPlugins->RunHook('imap.after-connect', array($this, $oImapClient, $oSettings));
$oSettings->Password = $this->IncPassword(); $oSettings->Password = $this->IncPassword();
return $this->netClientLogin($oImapClient, $oPlugins, $oSettings); return $this->netClientLogin($oImapClient, $oPlugins);
} }
public function SmtpConnectAndLogin(\RainLoop\Plugins\Manager $oPlugins, \MailSo\Smtp\SmtpClient $oSmtpClient) : bool public function SmtpConnectAndLogin(\RainLoop\Plugins\Manager $oPlugins, \MailSo\Smtp\SmtpClient $oSmtpClient) : bool
@ -251,7 +251,7 @@ abstract class Account implements \JsonSerializable
$oSettings->useAuth = false; $oSettings->useAuth = false;
return true; return true;
} }
$oSmtpClient->Connect($oSettings, $oSettings->Ehlo); $oSmtpClient->Connect($oSettings);
$oPlugins->RunHook('smtp.after-connect', array($this, $oSmtpClient, $oSettings)); $oPlugins->RunHook('smtp.after-connect', array($this, $oSmtpClient, $oSettings));
/* /*
if ($this->oDomain->OutAskCredentials() && !($this->sSmtpPassword && $this->sSmtpLogin)) { if ($this->oDomain->OutAskCredentials() && !($this->sSmtpPassword && $this->sSmtpLogin)) {
@ -259,7 +259,7 @@ abstract class Account implements \JsonSerializable
} }
*/ */
$oSettings->Password = $this->sSmtpPassword ?: $this->sPassword; $oSettings->Password = $this->sSmtpPassword ?: $this->sPassword;
return $this->netClientLogin($oSmtpClient, $oPlugins, $oSettings); return $this->netClientLogin($oSmtpClient, $oPlugins);
} }
public function SieveConnectAndLogin(\RainLoop\Plugins\Manager $oPlugins, \MailSo\Sieve\SieveClient $oSieveClient, \RainLoop\Config\Application $oConfig) public function SieveConnectAndLogin(\RainLoop\Plugins\Manager $oPlugins, \MailSo\Sieve\SieveClient $oSieveClient, \RainLoop\Config\Application $oConfig)
@ -274,10 +274,10 @@ abstract class Account implements \JsonSerializable
$oPlugins->RunHook('sieve.after-connect', array($this, $oSieveClient, $oSettings)); $oPlugins->RunHook('sieve.after-connect', array($this, $oSieveClient, $oSettings));
$oSettings->Password = $this->IncPassword(); $oSettings->Password = $this->IncPassword();
return $this->netClientLogin($oSieveClient, $oPlugins, $oSettings); return $this->netClientLogin($oSieveClient, $oPlugins);
} }
private function netClientLogin(\MailSo\Net\NetClient $oClient, \RainLoop\Plugins\Manager $oPlugins, \MailSo\Net\ConnectSettings $oSettings) : bool private function netClientLogin(\MailSo\Net\NetClient $oClient, \RainLoop\Plugins\Manager $oPlugins) : bool
{ {
/* /*
$encrypted = !empty(\stream_get_meta_data($oClient->ConnectionResource())['crypto']); $encrypted = !empty(\stream_get_meta_data($oClient->ConnectionResource())['crypto']);
@ -288,6 +288,7 @@ abstract class Account implements \JsonSerializable
[cipher_version] => TLSv1.3 [cipher_version] => TLSv1.3
) )
*/ */
$oSettings = $oClient->Settings;
$oSettings->ProxyAuthUser = $this->sProxyAuthUser; $oSettings->ProxyAuthUser = $this->sProxyAuthUser;
$oSettings->ProxyAuthPassword = $this->sProxyAuthPassword; $oSettings->ProxyAuthPassword = $this->sProxyAuthPassword;