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, \MailSo\Imap\Settings $oSettings) { // Check for mail.$DOMAIN as entered value in RL settings if ('auto' === $oSettings->host) { $domain = \substr(\strrchr($oAccount->Email(), '@'), 1); $mxhosts = array(); if (\getmxrr($domain, $mxhosts) && $mxhosts) { $oSettings->host = $mxhosts[0]; } else { $oSettings->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, \MailSo\Smtp\Settings $oSettings) { // Check for mail.$DOMAIN as entered value in RL settings if ('auto' === $oSettings->host) { $domain = \substr(\strrchr($oAccount->Email(), '@'), 1); $mxhosts = array(); if (\getmxrr($domain, $mxhosts) && $mxhosts) { $oSettings->host = $mxhosts[0]; } else { $oSettings->host = $this->smtp_prefix . $domain; } } } }