From 28ef275cde1c8738eaa8baa1b728107daeaac311 Mon Sep 17 00:00:00 2001 From: Jabari Hunt Date: Mon, 1 Jan 2018 15:11:21 -0600 Subject: [PATCH] Restored the original validateEmail() method. Created a new method called validateEmailDNS() that validates both the email address itself (using the ValidateEmail() method) as well as the domain name in the email address. --- src/Valitron/Validator.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Valitron/Validator.php b/src/Valitron/Validator.php index dfc594d..f085bb5 100644 --- a/src/Valitron/Validator.php +++ b/src/Valitron/Validator.php @@ -495,18 +495,26 @@ class Validator * @param mixed $value * @return bool */ - protected function validateEmail($field, $value, $checkDomain = false) + protected function validateEmail($field, $value) { - $emailIsValid = false; - if (filter_var($value, \FILTER_VALIDATE_EMAIL) !== false) { - $emailIsValid = true; - if ($checkDomain) { - $domain = idn_to_ascii(ltrim(stristr($value, '@'), '@'), 0, INTL_IDNA_VARIANT_UTS46) . '.'; - if (!checkdnsrr($domain, 'ANY')) {$emailIsValid = false;} - } + return filter_var($value, \FILTER_VALIDATE_EMAIL) !== false; + } + + /** + * Validate that a field is a valid e-mail address and the domain name is active + * + * @param string $field + * @param mixed $value + * @return bool + */ + protected function validateEmailDNS($field, $value) + { + if ($this->validateEmail($field, $value)) { + $domain = ltrim(stristr($value, '@'), '@') . '.'; + return checkdnsrr($domain, 'ANY'); } - return $emailIsValid; + return false; } /**