ZF-3635: Zend_Validate_EmailAddress should not validateMx if hostname does not validate.


If the hostname validation failled, I think it's useless to check for MX records. Plus, it produce too much errors. For exemple : using an email like name@IP using the default Zend_Validate_Hostname::ALLOW_DNS and setting $validateMx to true, will produce 3 errors : Zend_Validate_EmailAddress::INVALID_HOSTNAME Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED Zend_Validate_EmailAddress::INVALID_MX_RECORD

That last error should be avoid : since the domain name is not valid, why would we want to check if an MX record exists for this invalid domain name?

Or, if I miss a point, we should at least have an option like the $breakChainOnFailure used inside the Zend_Validate_EmailAddress


Index: ZendFramework/1.5.2/library/Zend/Validate/EmailAddress.php

--- ZendFramework/1.5.2/library/Zend/Validate/EmailAddress.php (revision 5) +++ ZendFramework/1.5.2/library/Zend/Validate/EmailAddress.php (working copy) @@ -187,7 +187,7 @@ foreach ($this->hostnameValidator->getErrors() as $error) { $this->_errors[] = $error; } - } + } else

     // MX check on hostname via dns_get_record()
     if ($this->_validateMx) {

Implemented with r13101