简体   繁体   中英

Codeigniter 3.1.7 valid_email issue

I have two sites using Codeigniter . Today I have updated sites to Codeigniter 3.1.7 (from 3.1.6 ). After that at one of this sites email validation had broken, valid_email validation rule doesn't work any more. On second site all fine. I had check out error logs and found error:

ERROR - 2018-02-06 10:13:21 --> Severity: Warning --> idn_to_ascii() expects parameter 3 to be long, string given /public_html/system/libraries/Form_validation.php 1235

Codeigniter's changlog says:

Updated Form Validation Library rule valid_email to use INTL_IDNA_VARIANT_UTS46 for non-ASCII domain names.

It seems to me that INTL_IDNA_VARIANT_UTS46 constant is not defined. Site using PHP Version 5.6.30

How can I fix this issue?

I found discussion of this problem here .

Issue is outdated ICU library (ICU version 4.2.1 was installed)

Go to system/library/email.php and replace valid_email()

    public function valid_email($email)
    {
    if (function_exists('idn_to_ascii') && defined('INTL_IDNA_VARIANT_UTS46') && $atpos = strpos($email, '@'))
    {
        $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), 0, INTL_IDNA_VARIANT_UTS46);
    }
    return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
   }

只需获取最新的电子邮件库获取最新的 codeigniter zip 文件,然后转到 system->libraries->Email 文件,复制该电子邮件文件并将其粘贴到您之前的 Email.php 库文件中,然后它将起作用

I think there's a better way to sort out that issue. As we all know that email library not supported in php 7.2 and that's why error occured

idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated

Error Screenshot of codeigniter email library

Quick Solution :

  • --> Go to cPanel --> Select PHP version --> change it to 7.1 instead of 7.2

For my case. I am also facing this issue.

Error:

Severity: 8192 
Message: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated Filename: libraries/Form_validation.php 
Line Number: 1234

I downloaded the Latest CodeIgniter version. Then from the system/libraries folder copied Email.php and Form_validation.php . Then replaced with Existing Email.php and Form_validation.php at the same path.

After replace, It is start working Fine..!!

Thanks @Evgeny for Guide.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM