2

I have Installed Fresh Magento2.3 php version 7.2.12 . When System try to send any email like order,contact,register customer etc .. .

it will through Exception and not sending any email

main.CRITICAL: Deprecated Functionality: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated in /public_html/vendor/zendframework/zend-validator/src/EmailAddress.php on line 560

error throw from here:

 if (extension_loaded('intl')) {
            if (defined('INTL_IDNA_VARIANT_UTS46')) {
                return (idn_to_ascii($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email);
            }
            return (idn_to_ascii($email) ?: $email);
        }
2
  • Can you specify your enviroment? mysql version. Dec 15, 2018 at 10:14
  • Magento : 2.3 php : 7.2.12 mysql : 5.0.12 Dec 17, 2018 at 4:54

8 Answers 8

8

in magento: 2.3, php: 7.2 I got same error: Deprecated Functionality: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated ..

so I downgrade php version to 7.1 then its work. http://php.net/manual/en/migration72.deprecated.php

or another solution is to upgrade icu to ICU 4.6 http://www.linuxfromscratch.org/blfs/view/8.3/general/icu.html

to check icu current vesion uconv -V

INTL_IDNA_VARIANT_2003 (integer) Use IDNA 2003 algorithm in idn_to_utf8() and idn_to_ascii(). This is the default. This constant and using the default has been deprecated as of PHP 7.2.0.

INTL_IDNA_VARIANT_UTS46 (integer) Use UTS #46 algorithm in idn_to_utf8() and idn_to_ascii(). Available as of ICU 4.6.

5

For avoiding the error: Deprecated Functionality add error_reporting(E_ALL ^ E_DEPRECATED); into bootstrap.php so email are works

2
  • its works for me php@72
    – matinict
    Feb 14, 2020 at 16:24
  • I decided to use this for now as logically Zend and PHP will fix this eventually. Also, Zend itself will be deprecated by 2.4
    – iphigenie
    Apr 21, 2020 at 8:13
2

In my case, Magento 2.3.4 instance running on PHP 7.2.27, no changes/downgrade made in the php version.

Working for me after did the below changes into EmailAddress.php file. add the @ before idn_to_ascii

vendor/zendframework/zend-validator/src/EmailAddress.php on line 560

protected function idnToAscii($email)
{
    if (extension_loaded('intl')) {
        if (defined('INTL_IDNA_VARIANT_UTS46')) {
            return (idn_to_ascii($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email);
        }
        return (@idn_to_ascii($email) ?: $email);
    }
    return $email;
}
1

In my case, Magento 2.3 instance running on PHP 7.2, no changes/downgrade made in the php version.

Working for me after did the below changes into EmailAddress.php file.

vendor/zendframework/zend-validator/src/EmailAddress.php on line 560
vendor/zendframework/zend-validator/src/EmailAddress.php on line 538

Function name idnToAscii

protected function idnToAscii($email)
{
    if (extension_loaded('intl')) {
        if (version_compare(phpversion(), '7.2', '>')) {
        if (defined('INTL_IDNA_VARIANT_UTS46')) {
            return (idn_to_ascii($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email);
            }
        }
        return (idn_to_ascii($email) ?: $email);
    }
    return $email;
}

Function name idnToUtf8

protected function idnToUtf8($email)
{
    if (extension_loaded('intl')) {
        // The documentation does not clarify what kind of failure
        // can happen in idn_to_utf8. One can assume if the source
        // is not IDN encoded, it would fail, but it usually returns
        // the source string in those cases.
        // But not when the source string is long enough.
        // Thus we default to source string ourselves.
        if (version_compare(phpversion(), '7.2', '>')) {
        if (defined('INTL_IDNA_VARIANT_UTS46')) {
            return idn_to_utf8($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email;
        }
        return idn_to_utf8($email) ?: $email;
        } else {
        return idn_to_utf8($email) ?: $email;
        }
        return idn_to_utf8($email) ?: $email;
    }
    return $email;
}
1

when installing magento 2.3.5 the correct way to change the file is:

/public_html/vendor/laminas/laminas-validator/src/EmailAddress.php

on line 560

Edit the file as follows:

FROM: return idn_to_ascii ($ email)?: $ Email; TO: return (@idn_to_ascii ($ email)?: $ Email);

1
  • i was surprised this hadn't been fixed in 2.3.5!
    – iphigenie
    Aug 10, 2020 at 8:45
0

Had the same error. You're probably using php7.2 or 7.3. Just downgrade to 7.1 and it'll work like a charm!

Tested!

0

No need to downgrade to php 7.1 or 7.2. It worked for me just by adding below code at line 560 for the function idnToAscii($email).

return (@idn_to_ascii($email) ?: $email);
0

For me it works both ways

  1. Either downgrade the php version to 7.1 or
  2. in File vendor/zendframework/zend-validator/src/EmailAddress.php on line 560

update the line to return (@idn_to_ascii($email) ?: $email);

this worked for me in Magento ver. 2.3.3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.