mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-26 00:51:24 +08:00
Cleanup some mail address parsing
This commit is contained in:
parent
04a78ad8bd
commit
728286d16c
4 changed files with 9 additions and 15 deletions
|
@ -433,15 +433,8 @@ abstract class Utils
|
|||
|
||||
public static function GetDomainFromEmail(string $sEmail) : string
|
||||
{
|
||||
$sResult = '';
|
||||
if (\strlen($sEmail)) {
|
||||
$iPos = \strrpos($sEmail, '@');
|
||||
if (false !== $iPos && 0 < $iPos) {
|
||||
$sResult = \substr($sEmail, $iPos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $sResult;
|
||||
$aParts = \explode('@', $sEmail);
|
||||
return isset($aParts[1]) ? \array_pop($aParts) : '';
|
||||
}
|
||||
|
||||
public static function GetClearDomainName(string $sDomain) : string
|
||||
|
|
|
@ -27,13 +27,13 @@ trait UserAuth
|
|||
string &$sPassword,
|
||||
string &$sLogin): void
|
||||
{
|
||||
$this->Plugins()->RunHook('login.credentials.step-1', array(&$sEmail));
|
||||
|
||||
$sEmail = \MailSo\Base\Utils::Trim($sEmail);
|
||||
if ($this->Config()->Get('login', 'login_lowercase', true)) {
|
||||
$sEmail = \mb_strtolower($sEmail);
|
||||
}
|
||||
|
||||
$this->Plugins()->RunHook('login.credentials.step-1', array(&$sEmail));
|
||||
|
||||
if (!\str_contains($sEmail, '@')) {
|
||||
$this->logWrite('The email address "' . $sEmail . '" is not complete', \LOG_INFO, 'LOGIN');
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@ abstract class Autoconfig
|
|||
{
|
||||
public static function discover(string $emailaddress) : ?array
|
||||
{
|
||||
$domain = \explode('@', $emailaddress);
|
||||
$domain = \array_pop($domain);
|
||||
$domain = \MailSo\Base\Utils::GetDomainFromEmail($emailaddress);
|
||||
// First try
|
||||
$autoconfig = static::resolve($domain, $emailaddress);
|
||||
if ($autoconfig) {
|
||||
|
|
|
@ -62,8 +62,10 @@ abstract class IDN
|
|||
|
||||
private static function emailAddress(string $address, bool $toAscii) : string
|
||||
{
|
||||
if (\strpos($address, '@')) {
|
||||
list($local, $domain) = \explode('@', $address, 2);
|
||||
if (\str_contains($address, '@')) {
|
||||
$local = \explode('@', $address);
|
||||
$domain = \array_pop($local);
|
||||
$local = \implode('@', $local);
|
||||
$arr = \explode('.', $domain);
|
||||
foreach ($arr as $k => $v) {
|
||||
$conv = $toAscii ? static::toAscii($v) : static::toUtf8($v);
|
||||
|
|
Loading…
Reference in a new issue