mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Merge pull request #1802 from PlanetHoster/auto-grab-mx
auto-domain-grab use MX record for Host
This commit is contained in:
commit
2faf418f27
1 changed files with 20 additions and 4 deletions
|
|
@ -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 \RainLoop\Model\Account $oAccount
|
||||||
* @param array $aImapCredentials
|
* @param array $aImapCredentials
|
||||||
|
|
@ -36,13 +36,21 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
if (!empty($aImapCredentials['Host']) && 'auto' === $aImapCredentials['Host'])
|
if (!empty($aImapCredentials['Host']) && 'auto' === $aImapCredentials['Host'])
|
||||||
{
|
{
|
||||||
$domain = substr(strrchr($oAccount->Email(), "@"), 1);
|
$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;
|
$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.
|
* 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 \RainLoop\Model\Account $oAccount
|
||||||
* @param array $aSmtpCredentials
|
* @param array $aSmtpCredentials
|
||||||
|
|
@ -55,8 +63,16 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
if (!empty($aSmtpCredentials['Host']) && 'auto' === $aSmtpCredentials['Host'])
|
if (!empty($aSmtpCredentials['Host']) && 'auto' === $aSmtpCredentials['Host'])
|
||||||
{
|
{
|
||||||
$domain = substr(strrchr($oAccount->Email(), "@"), 1);
|
$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;
|
$aSmtpCredentials['Host'] = $this->smtp_prefix.$domain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue