addHook('smtp.before-connect', 'FilterSmtpCredentials'); $this->addHook('imap.before-connect', 'FilterImapCredentials'); } /** * This function detects the IMAP Host, and if it is set to 'auto', replaces it with the MX or email domain. */ public function FilterImapCredentials(\RainLoop\Model\Account $oAccount, \MailSo\Imap\ImapClient $oImapClient, array &$aImapCredentials) { // Check for mail.$DOMAIN as entered value in RL settings if (!empty($aImapCredentials['Host']) && 'auto' === $aImapCredentials['Host']) { $domain = \substr(\strrchr($oAccount->Email(), '@'), 1); $mxhosts = array(); if (\getmxrr($domain, $mxhosts) && $mxhosts) { $aImapCredentials['Host'] = $mxhosts[0]; } else { $aImapCredentials['Host'] = $this->imap_prefix.$domain; } } } /** * This function detects the SMTP Host, and if it is set to 'auto', replaces it with the MX or email domain. */ public function FilterSmtpCredentials(\RainLoop\Model\Account $oAccount, \MailSo\Smtp\SmtpClient $oSmtpClient, array &$aSmtpCredentials) { // Check for mail.$DOMAIN as entered value in RL settings if (!empty($aSmtpCredentials['Host']) && 'auto' === $aSmtpCredentials['Host']) { $domain = \substr(\strrchr($oAccount->Email(), '@'), 1); $mxhosts = array(); if (\getmxrr($domain, $mxhosts) && $mxhosts) { $aSmtpCredentials['Host'] = $mxhosts[0]; } else { $aSmtpCredentials['Host'] = $this->smtp_prefix . $domain; } } } }