Categories
Programming

Magento Fix – Email Validation for New gTLDs

Have you come across the following errors in Magento?

  • Invalid email address “[email protected]
  • [email protected]” is not a valid hostname.
  • ‘domain.events’ appears to be a DNS hostname but cannot match TLD against known list
  • ‘domain.events’ appears to be a local network name but local network names are not allowed

It is probably because the Zend email validation library is not uptodate with all the new gTLDs that are being released.

Copy
/lib/Zend/Validate/Hostname.php
to
/app/code/local/Zend/Validate/Hostname.php

Navigate to line 539 and comment out the following lines of code. This is where the domain name is checked against an array of validTlds.

if (!in_array($this->_tld, $this->_validTlds)) {
    // $this->_error(self::UNKNOWN_TLD);
    // $status = false;
    // break;
}

The alternative is to add all possible TLDs into the validTlds array. I prefer the above method as I do not have to keep updating the validTlds array with hundreds of new gTLDs.

By Kathir Vel

An agile ebusiness & marketing consultant based in Edinburgh, Scotland, UK. ICT specialist with a MBA in marketing and strategy. Seasoned project manager with strong roots in advertising campaigns and film making. Loves photography and travelling.

3 replies on “Magento Fix – Email Validation for New gTLDs”

Leave a Reply

Your email address will not be published. Required fields are marked *