[PHP] simple email validation ereg
Hi, I know that there are more complex functions and classes out there for validating email address', but some of them do return "invalid" on *technically* valid, although uncommon email address', so all I want is a simple test for: (anything)@(anything) followed by 1 or more (.anything) ie foo@foo : invalid [EMAIL PROTECTED] : valid [EMAIL PROTECTED] : valid i wish to allow ANYTHING really -- not just a-z,A-z,0-9,_,- technically spaces, brackets, and all sorts of crap are valid in the user portion of the email address :) this will return true for [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] etc etc... i'm aware that the results will not necessarily BE valid email address', but at least they'll *look* like valid email address'. it's for a simple guestbook/message board where some creative people have put in "lalaland" or "myplace" as an email address, rather than entering something that at least LOOKS like a valid address, or optionally leaving the field blank. my aim will be to strip out anything that doesn't at least LOOK like like an email address. regards, justin french -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple email validation ereg
Maybe I'm biased, but if you grab validateEmailFormat.php from www.killersoft.com, you'd be able to do something as simple as this: validateEmailFormat.php is a translation of the Perl regular expression that's widely considered to be the defintive test of a valid RFC822 address. Can't go wrong with that. : ) -Clay > From: Justin French <[EMAIL PROTECTED]> > Date: Sun, 02 Jun 2002 14:13:40 +1000 > To: php <[EMAIL PROTECTED]> > Subject: [PHP] simple email validation ereg > > Hi, > > I know that there are more complex functions and classes out there for > validating email address', but some of them do return "invalid" on > *technically* valid, although uncommon email address', so all I want is a > simple test for: > > (anything)@(anything) followed by 1 or more (.anything) > > ie > foo@foo : invalid > [EMAIL PROTECTED] : valid > [EMAIL PROTECTED] : valid > > i wish to allow ANYTHING really -- not just a-z,A-z,0-9,_,- technically > spaces, brackets, and all sorts of crap are valid in the user portion of the > email address :) > > > this will return true for [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] > etc etc... i'm aware that the results will not necessarily BE valid email > address', but at least they'll *look* like valid email address'. > > it's for a simple guestbook/message board where some creative people have > put in "lalaland" or "myplace" as an email address, rather than entering > something that at least LOOKS like a valid address, or optionally leaving > the field blank. > > my aim will be to strip out anything that doesn't at least LOOK like like an > email address. > > > regards, > > justin french > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple email validation ereg
Hi Justin: On Sun, Jun 02, 2002 at 02:13:40PM +1000, Justin French wrote: > > (anything)@(anything) followed by 1 or more (.anything) So, what ereg expressions have you tried thus far? It's far cooler to come to the list saying, "I tried x, and it's generating error y, does anyone have an idea?" --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple email validation ereg
Justin French wrote: >my aim will be to strip out anything that doesn't at least LOOK like like an >email address. > Well, instead of coming up with some "clever" regexp, I'd suggest to completely dump syntax checks. Instead, I only check if the host has a MX entry associated. If not, then this host either does not exist, or mails wouldn't get through. At any rate, it's not a valid adress. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple email validation ereg
On Monday 03 June 2002 04:42, Alexander Skwar wrote: > Justin French wrote: > >my aim will be to strip out anything that doesn't at least LOOK like like > > an email address. > > Well, instead of coming up with some "clever" regexp, I'd suggest to > completely dump syntax checks. Instead, I only check if the host has a > MX entry associated. If not, then this host either does not exist, or > mails wouldn't get through. At any rate, it's not a valid adress. The lack of an MX record doesn't necessarily mean mail will not get through, so you cannot use that as a test for whether the address is valid. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Who needs friends when you can sit alone in your room and drink? */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple email validation ereg
So sprach Jason Wong am 2002-06-03 um 12:10:29 +0800 : > The lack of an MX record doesn't necessarily mean mail will not get through, > so you cannot use that as a test for whether the address is valid. It will not? Do you have an example? How is a mail server supposed to know where the mail should be delivered if there's no MX? Alexander Skwar -- How to quote: http://learn.to/quote (german) http://quote.6x.to (english) Homepage: http://www.iso-top.de |Jabber: [EMAIL PROTECTED] iso-top.de - Die günstige Art an Linux Distributionen zu kommen Uptime: 2 days 21 hours 18 minutes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple email validation ereg
On Monday 03 June 2002 21:35, Alexander Skwar wrote: > So sprach Jason Wong am 2002-06-03 um 12:10:29 +0800 : > > The lack of an MX record doesn't necessarily mean mail will not get > > through, so you cannot use that as a test for whether the address is > > valid. > > It will not? Do you have an example? How is a mail server supposed to > know where the mail should be delivered if there's no MX? For domains without an MX record the MTA should try to deliver to the IP address. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* E.T. GO HOME!!! (And take your Smurfs with you.) */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple email validation ereg
On Mon, 3 Jun 2002, Alexander Skwar wrote: > So sprach Jason Wong am 2002-06-03 um 12:10:29 +0800 : >> The lack of an MX record doesn't necessarily mean mail will not get >> through, so you cannot use that as a test for whether the address is >> valid. > > It will not? Do you have an example? How is a mail server supposed to > know where the mail should be delivered if there's no MX? By looking up the A record. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php