diff --git a/libraries/src/Mail/Mail.php b/libraries/src/Mail/Mail.php index c36074a7ff32a..cd5207c679538 100644 --- a/libraries/src/Mail/Mail.php +++ b/libraries/src/Mail/Mail.php @@ -65,16 +65,24 @@ public function __construct($exceptions = true) // Don't disclose the PHPMailer version $this->XMailer = ' '; - /* - * PHPMailer 5.2 can't validate e-mail addresses with the new regex library used in PHP 7.3+ - * Setting $validator to "php" uses the native php function filter_var - * - * @see https://github.com/joomla/joomla-cms/issues/24707 - */ - if (version_compare(PHP_VERSION, '7.3.0', '>=')) - { - \PHPMailer::$validator = 'php'; - } + + /** + * Which validator to use by default when validating email addresses. + * Validation patterns supported: + * `auto` Pick best pattern automatically; + * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0; + * `pcre` Use old PCRE implementation; + * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; + * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. + * `noregex` Don't use a regex: super fast, really dumb. + * + * The default used by phpmailer is `php` but this does not support dotless domains so instead we use `html5` + * + * @see PHPMailer::validateAddress() + * + * @var string|callable + */ + \PHPMailer::$validator = 'html5'; } /**