From 2898ecc5e06738486f1f26849472aaf4fc8cab32 Mon Sep 17 00:00:00 2001 From: Gabriel P Date: Thu, 29 Nov 2018 12:00:25 -0500 Subject: [PATCH 1/2] auto-domain-grab use MX record for Host --- plugins/auto-domain-grab/index.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/plugins/auto-domain-grab/index.php b/plugins/auto-domain-grab/index.php index b4bfc5763..9edc7c4e4 100644 --- a/plugins/auto-domain-grab/index.php +++ b/plugins/auto-domain-grab/index.php @@ -36,7 +36,15 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin if (!empty($aImapCredentials['Host']) && 'auto' === $aImapCredentials['Host']) { $domain = substr(strrchr($oAccount->Email(), "@"), 1); - $aImapCredentials['Host'] = $this->imap_prefix.$domain; + $mxhosts = array(); + if(getmxrr($domain, $mxhosts) && sizeof($mxhosts) > 0) + { + $aImapCredentials['Host'] = $mxhosts[0]; + } + else + { + $aImapCredentials['Host'] = $this->imap_prefix.$domain; + } } } } @@ -55,7 +63,15 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin if (!empty($aSmtpCredentials['Host']) && 'auto' === $aSmtpCredentials['Host']) { $domain = substr(strrchr($oAccount->Email(), "@"), 1); - $aSmtpCredentials['Host'] = $this->smtp_prefix.$domain; + $mxhosts = array(); + if(getmxrr($domain, $mxhosts) && sizeof($mxhosts) > 0) + { + $aSmtpCredentials['Host'] = $mxhosts[0]; + } + else + { + $aSmtpCredentials['Host'] = $this->smtp_prefix.$domain; + } } } } From 134c99624c5439b292796aafe1936dd16ea4db2a Mon Sep 17 00:00:00 2001 From: Gabriel P Date: Thu, 29 Nov 2018 12:26:22 -0500 Subject: [PATCH 2/2] update comment --- plugins/auto-domain-grab/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/auto-domain-grab/index.php b/plugins/auto-domain-grab/index.php index 9edc7c4e4..a2174926d 100644 --- a/plugins/auto-domain-grab/index.php +++ b/plugins/auto-domain-grab/index.php @@ -23,7 +23,7 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin } /** - * This function detects the IMAP Host, and if it is set to "auto", replaces it with the email domain. + * This function detects the IMAP Host, and if it is set to "auto", replaces it with the MX or email domain. * * @param \RainLoop\Model\Account $oAccount * @param array $aImapCredentials @@ -50,7 +50,7 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin } /** - * This function detects the SMTP Host, and if it is set to "auto", replaces it with the email domain. + * This function detects the SMTP Host, and if it is set to "auto", replaces it with the MX or email domain. * * @param \RainLoop\Model\Account $oAccount * @param array $aSmtpCredentials