Codeigniter 3.1.7 valid_email issue

13,986

Solution 1

I found discussion of this problem here.

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

Solution 2

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);
   }

Solution 3

just get the latest library for email Get the latest codeigniter zip file then go to system->libraries->Email file copy that email file and paste it into your previous Email.php library file then it will work

Solution 4

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
Share:
13,986

Related videos on Youtube

Evgeny
Author by

Evgeny

Just another one programmer :)

Updated on September 15, 2022

Comments

  • Evgeny
    Evgeny over 1 year

    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?

  • October Eleven
    October Eleven over 4 years
    Both Email.php and Form_validation.php libraries need to be replaced with new ones. Thanks for this suggestion / worked great!
  • Evgeny
    Evgeny about 4 years
    When this question was asked Codeigniter 3.1.7 was the latest version.
  • Evgeny
    Evgeny about 4 years
    It’s natural that you always need to update to the latest version, but when the question was asked, 3.1.7 was the latest version
  • Evgeny
    Evgeny about 4 years
    Did you read the question? PHP Version 5.6.30 was used on site.
  • Chandan Sharma
    Chandan Sharma about 4 years
    There was Bug . Later it was fixed in the latest system library.