1

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);
        }
  • Can you specify your enviroment? mysql version. – Milind Singh Dec 15 '18 at 10:14
  • Magento : 2.3 php : 7.2.12 mysql : 5.0.12 – Abdul Kadir Dec 17 '18 at 4:54
6

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.

| improve this answer | |
4

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

| improve this answer | |
  • its works for me php@72 – matinict Feb 14 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 at 8:13
1

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!

| improve this answer | |
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;
}
| improve this answer | |
1

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;
}
| improve this answer | |
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);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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