When i tried to register with an email on magento store that I am developing I came across with errors that i havent seen before that says:
"Email" is not a valid hostname
does not appear to be a valid local network name
appears to be a DNS hostname but cannot match TLD against known list magento
When I did my research I foundout that these errors comes are caused by the Zend hostname validation.
Is it possible to resolve these or there's no solution at all
I encountered same error :
"Email" is not a valid hostname.
'example.example' appears to be a DNS hostname but cannot match TLD against known list
'example.example' appears to be a local network name but local network names are not allowed
From Magento 1, it appears that Zend is using a hardcoded list of Tlds :
/**
* Array of valid top-level-domains
*
* @see ftp://data.iana.org/TLD/tlds-alpha-by-domain.txt List of all TLDs by domain
* @see http://www.iana.org/domains/root/db/ Official list of supported TLDs
* @var array
*/
protected $_validTlds = array(
'ac', 'ad', 'ae', 'aero', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'arpa',
[...]
'ye', 'yt', 'yu', 'za', 'zm', 'zw'
);
So, there are some options :
For Option 2 we can perform a safe-upgrade of the following file, or see option 3 to add $validator->getHostnameValidator()->setValidateTld(false);
, copying it from :
/lib/Zend/Validate/Hostname.php
to :
/app/code/local/Zend/Validate/Hostname.php
Then look for this block of code, and just comment the three lines :
if (!in_array($this->_tld, $this->_validTlds)) {
// $this->_error(self::UNKNOWN_TLD);
// $status = false;
// break;
}
For Option 3 we can perform a safe-upgrade of the following file, copying it from :
app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php
to :
/app/code/local/Mage/Eav/Model/Attribute/Data/Abstract.php
Then replace this code :
$validator = new Zend_Validate_EmailAddress();
by :
// 1. we check mx record
$validator = new Zend_Validate_EmailAddress(
array(
'allow' => Zend_Validate_Hostname::ALLOW_DNS,
'mx' => true
)
);
// 2. we remove TLD validation :
$validator->getHostnameValidator()->setValidateTld(false);
Do not forget to look for every call of the Zend_Validate_EmailAddress
class that can be used in community or custom extensions (e.g : onestepcheckout).