.+)@(?.+)$/u', $value, $m)) { return false; } $m['name'] = $idn($m['name']); if ($m['name'] === null) { return false; } $m['domain'] = $idn($m['domain']); if ($m['domain'] === null) { return false; } $value = $m['name'] . '@' . $m['domain']; } return filter_var($value, FILTER_VALIDATE_EMAIL) !== false; } /** * @return callable|null */ public static function idn(): ?callable { if (static::$idn === false) { if (function_exists('idn_to_ascii')) { static::$idn = static function (string $value): ?string { /** @noinspection PhpComposerExtensionStubsInspection */ $value = idn_to_ascii($value, 0, INTL_IDNA_VARIANT_UTS46); return is_string($value) ? $value : null; }; } else { static::$idn = null; } } return static::$idn; } }