valid_email litlle bug |
[eluser]Mareshal[/eluser]
I have a problem with "valid_email" because the function validates this email: "[email protected]" as a valid email. is returning TRUE instead of FALSE. To solve this problem I've added in config.php this code: $config['tld'] = array('com', 'net', 'biz'); //etc and with valid_email I am checking if "comm" is in my array or not.
[eluser]Dam1an[/eluser]
I'm not really sure if this is a bug, as I don't think that function was ever meant to check against valid TLDs, but to check the format is correct, no disallowed chars etc Also, now that you restrict it to a predefined set of TLDs, chances are you've missed some, or need to manually update it every time a new TLD appears. And why not take it a step firther and do a whois lookup to check the domain they entered is valid
[eluser]Ihab Khattab[/eluser]
I like this approach using checkdnsrr http://www.sitepoint.com/article/users-e...dress-php/ I hope to see it implemented in the next CI version
[eluser]sophistry[/eluser]
dns check only tells you if the domain has an MX record - it doesn't check the mailbox part. that's a start. also, a DNS check for every email can be pretty resource intensive and it exposes you to network problems during email acquisition. i wrote some code that fetches the IANA list of TLDs and sort is according to popularity. this lets me prepare an optimized set of TLDs for a regex. Code: function tlds()
[eluser]Michael Wales[/eluser]
.comm is a valid TLD, as is .omgicannislettingpeoplepurchasestheirowntldstodowhatevertheywantwithsoon Not a bug.
[eluser]sophistry[/eluser]
not to nitpick over hypotheticals, but it's a slow morning... actually, .comm probably wouldn't be accepted: Quote:Strings must not be confusingly similar to an existing top-level domain or a Reservedhttp://losangeles2007.icann.org/files/lo...3oct07.pdf also, the string in the example is 72 chararcters long - upper limit for TLDs is proposed to be 64 chars. valid_email() is a misnomer. the function should be called "looks_like_it_might_be_an_email()" cheers.
[eluser]Michael Wales[/eluser]
haha, touche My point was, valid TLDs aren't just limited to what you see on the frontpage of GoDaddy.com. Truly validating an email is hard and resource intensive. I like sophistry's suggestion: when you see valid_email() think looks_like_it_might_be_an_email()
[eluser]Mareshal[/eluser]
I took major tlds from wikipedia, sites which I can accept on my site: $config ['tlds'] = array('com', 'net', 'org', 'biz', 'us', 'info', 'name', 'pro', 'aero', 'asia', 'edu', 'mobi', 'tel'); and a good solution is to check MX records of the domain
|
Welcome Guest, Not a member yet? Register Sign In |