Codeigniter 3.1.7 valid_email issue
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
Related videos on Youtube
Comments
-
Evgeny over 1 year
I have two sites using
Codeigniter
. Today I have updated sites toCodeigniter 3.1.7
(from3.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 usingPHP Version 5.6.30
How can I fix this issue?
-
October Eleven over 4 yearsBoth
Email.php
andForm_validation.php
libraries need to be replaced with new ones. Thanks for this suggestion / worked great! -
Evgeny about 4 yearsWhen this question was asked Codeigniter 3.1.7 was the latest version.
-
Evgeny about 4 yearsIt’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 about 4 yearsDid you read the question?
PHP Version 5.6.30
was used on site. -
Chandan Sharma about 4 yearsThere was Bug . Later it was fixed in the latest system library.