Welcome Guest, Not a member yet? Register   Sign In
valid_email - not sure this is working here!
#1

[eluser]nealumney[/eluser]
Hi,

I'm a relative newbie, but getting to grips with this CI, which is making it easier to do things, but I am having some concerns about the valid_email rule.

I have set the rule to be:
array('field' => 'email', 'label'=> 'Email address', 'rules' => 'required|vaild_email')

When I try and use this, it accepts:

neal.umney@ (I think this is an invalid email address)
neal.umney@ithomepage (I think this is probably valid - same as nealumney@localhost?)
[email protected] (I think this is invalid)

Is there anywhere I can view what the allowable values are? Does CI support checking DNS? perhaps in the email class - I'll check that myself.

Thanks,

Neal
#2

[eluser]Choo[/eluser]
CI doesn't check DNS. CI checks e-mail using rather simple regular expression:
Code:
/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix

If you are not agree you can simply change it.
#3

[eluser]nealumney[/eluser]
Thanks Choo,

How do I change the regex?

Neal
#4

[eluser]TheFuzzy0ne[/eluser]
Code:
function checkEmail($email)
{
    if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email))
    {
        return FALSE;
    }

    list($username, $domain) = split("@",$email);

    if(getmxrr($domain, $mx_host) || fsockopen($domain, 25, $errno, $errstr, 30))
    {
         return TRUE;
    }
    return FALSE;
}

The above function checks for the existence of the domain, and also that an mx record exists, or that port 25 is open. It's great for picking up on typos, however, usually, just getting the user to confirm their Email address twice is enough.




Theme © iAndrew 2016 - Forum software by © MyBB