Пример #1
0
 /**
  * @param \RainLoop\Plugins\Manager $oPlugins
  * @param \MailSo\Smtp\SmtpClient|null $oSmtpClient
  * @param \RainLoop\Application $oConfig
  * @param bool $bUsePhpMail = false
  *
  * @return bool
  */
 public function OutConnectAndLoginHelper($oPlugins, $oSmtpClient, $oConfig, &$bUsePhpMail = false)
 {
     $bLogin = false;
     $aSmtpCredentials = array('UseConnect' => true, 'UseAuth' => $this->DomainOutAuth(), 'UsePhpMail' => $bUsePhpMail, 'Ehlo' => \MailSo\Smtp\SmtpClient::EhloHelper(), 'Host' => $this->DomainOutHost(), 'Port' => $this->DomainOutPort(), 'Secure' => $this->DomainOutSecure(), 'Login' => $this->OutLogin(), 'Password' => $this->Password(), 'ProxyAuthUser' => $this->ProxyAuthUser(), 'ProxyAuthPassword' => $this->ProxyAuthPassword(), 'VerifySsl' => !!$oConfig->Get('ssl', 'verify_certificate', false), 'AllowSelfSigned' => !!$oConfig->Get('ssl', 'allow_self_signed', true));
     $oPlugins->RunHook('filter.smtp-credentials', array($this, &$aSmtpCredentials));
     $bUsePhpMail = $aSmtpCredentials['UsePhpMail'];
     $oPlugins->RunHook('event.smtp-pre-connect', array($this, $aSmtpCredentials['UseConnect'], $aSmtpCredentials));
     if ($aSmtpCredentials['UseConnect'] && !$aSmtpCredentials['UsePhpMail'] && $oSmtpClient) {
         $oSmtpClient->Connect($aSmtpCredentials['Host'], $aSmtpCredentials['Port'], $aSmtpCredentials['Ehlo'], $aSmtpCredentials['Secure'], $aSmtpCredentials['VerifySsl'], $aSmtpCredentials['AllowSelfSigned']);
     }
     $oPlugins->RunHook('event.smtp-post-connect', array($this, $aSmtpCredentials['UseConnect'], $aSmtpCredentials));
     $oPlugins->RunHook('event.smtp-pre-login', array($this, $aSmtpCredentials['UseAuth'], $aSmtpCredentials));
     if ($aSmtpCredentials['UseAuth'] && !$aSmtpCredentials['UsePhpMail'] && $oSmtpClient) {
         $iGatLen = \strlen(APP_GOOGLE_ACCESS_TOKEN_PREFIX);
         $sPassword = $aSmtpCredentials['Password'];
         if (APP_GOOGLE_ACCESS_TOKEN_PREFIX === \substr($sPassword, 0, $iGatLen)) {
             $oSmtpClient->LoginWithXOauth2(\base64_encode('user='******'Login'] . "" . 'auth=Bearer ' . \substr($sPassword, $iGatLen) . ""));
         } else {
             $oSmtpClient->Login($aSmtpCredentials['Login'], $aSmtpCredentials['Password']);
         }
         $bLogin = true;
     }
     $oPlugins->RunHook('event.smtp-post-login', array($this, $aSmtpCredentials['UseAuth'], $bLogin, $aSmtpCredentials));
     return $bLogin;
 }
Пример #2
0
 /**
  * @param \RainLoop\Plugins\Manager $oPlugins
  * @param \MailSo\Smtp\SmtpClient|null $oSmtpClient
  * @param \RainLoop\Application $oConfig
  * @param bool $bUsePhpMail = false
  *
  * @return bool
  */
 public function OutConnectAndLoginHelper($oPlugins, $oSmtpClient, $oConfig, &$bUsePhpMail = false)
 {
     $bLogin = false;
     $aSmtpCredentials = array('UseConnect' => true, 'UseAuth' => $this->DomainOutAuth(), 'UsePhpMail' => $bUsePhpMail, 'Ehlo' => \MailSo\Smtp\SmtpClient::EhloHelper(), 'Host' => $this->DomainOutHost(), 'Port' => $this->DomainOutPort(), 'Secure' => $this->DomainOutSecure(), 'Login' => $this->OutLogin(), 'Password' => $this->Password(), 'ProxyAuthUser' => $this->ProxyAuthUser(), 'ProxyAuthPassword' => $this->ProxyAuthPassword(), 'VerifySsl' => !!$oConfig->Get('ssl', 'verify_certificate', false), 'AllowSelfSigned' => !!$oConfig->Get('ssl', 'allow_self_signed', true));
     $oPlugins->RunHook('filter.smtp-credentials', array($this, &$aSmtpCredentials));
     $bUsePhpMail = $aSmtpCredentials['UsePhpMail'];
     $oPlugins->RunHook('event.smtp-pre-connect', array($this, $aSmtpCredentials['UseConnect'], $aSmtpCredentials));
     if ($aSmtpCredentials['UseConnect'] && !$aSmtpCredentials['UsePhpMail'] && $oSmtpClient) {
         $oSmtpClient->Connect($aSmtpCredentials['Host'], $aSmtpCredentials['Port'], $aSmtpCredentials['Ehlo'], $aSmtpCredentials['Secure'], $aSmtpCredentials['VerifySsl'], $aSmtpCredentials['AllowSelfSigned']);
     }
     $oPlugins->RunHook('event.smtp-post-connect', array($this, $aSmtpCredentials['UseConnect'], $aSmtpCredentials));
     $oPlugins->RunHook('event.smtp-pre-login', array($this, $aSmtpCredentials['UseAuth'], $aSmtpCredentials));
     if ($aSmtpCredentials['UseAuth'] && !$aSmtpCredentials['UsePhpMail'] && $oSmtpClient) {
         $oSmtpClient->Login($aSmtpCredentials['Login'], $aSmtpCredentials['Password']);
         $bLogin = true;
     }
     $oPlugins->RunHook('event.smtp-post-login', array($this, $aSmtpCredentials['UseAuth'], $bLogin, $aSmtpCredentials));
     return $bLogin;
 }