auto-domain-grab use MX record for Host

This commit is contained in:
Gabriel P 2018-11-29 12:00:25 -05:00
parent 495fb486e1
commit 2898ecc5e0

View file

@ -36,10 +36,18 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin
if (!empty($aImapCredentials['Host']) && 'auto' === $aImapCredentials['Host'])
{
$domain = substr(strrchr($oAccount->Email(), "@"), 1);
$mxhosts = array();
if(getmxrr($domain, $mxhosts) && sizeof($mxhosts) > 0)
{
$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 email domain.
@ -55,8 +63,16 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin
if (!empty($aSmtpCredentials['Host']) && 'auto' === $aSmtpCredentials['Host'])
{
$domain = substr(strrchr($oAccount->Email(), "@"), 1);
$mxhosts = array();
if(getmxrr($domain, $mxhosts) && sizeof($mxhosts) > 0)
{
$aSmtpCredentials['Host'] = $mxhosts[0];
}
else
{
$aSmtpCredentials['Host'] = $this->smtp_prefix.$domain;
}
}
}
}
}