[PHP] Re: Richard Lynch's Email Address ...
On 11/9/05 7:20 PM, GamblerZG wrote: James Benson wrote: Would it not be better something like valid_email() email_validate()? Anyway, I agree that PHP needs such function. Check out http://pecl.php.net/package/filter I've been playing around with this for a while, and it should be noted that it's still in beta and should not be used in a production environment, but it's a promising step. The e-mail regex that's used isn't perfect, and it won't support RFC-compliant addresses, but I hope to put a little bit of work into it to help out with this. In the meantime, check out PEAR::Mail, which includes Mail_RFC822 that can be used to validate e-mail addresses. Also, if your PHP is compiled --with-imap, then you can use imap_rfc822_parse_adrlist() to validate e-mail addresses. -- Ben Ramsey http://benramsey.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Richard Lynch's Email Address ...
James Benson wrote: Would it not be better something like valid_email() email_validate()? Anyway, I agree that PHP needs such function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
I'm using this, but I'm not sure whether it's bug-free: preg_match('/^([.0-9a-z_+-]+)@([0-9a-z-]+\.)+[0-9a-z]{2,6}$/i', $email); Note: IIRC, PEAR function will invalidate all adresses in museum TLD. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
On Thu, November 3, 2005 8:16 am, Richard Heyes wrote: > Marcus Bointon wrote: >> The PEAR rfc822 class is pretty good, but it should be noted it's >> designed for parsing entire to, cc, bcc fields which may contain >> multiple addresses, and it's not quite as simple as asking it 'is >> this >> address ok'. > > News to me... > > if (!PEAR::isError(Mail_RFC822::parseAddressList('[EMAIL PROTECTED]'))) > { > // Valid... > } This one would accept: '[EMAIL PROTECTED],[EMAIL PROTECTED]' right? > It even has a method specifically for "normal" email addresses of the > form [EMAIL PROTECTED] > > if (Mail_RFC822::isValidInetAddress('[EMAIL PROTECTED]')) { > // Valid... > } But this one, for real, for sure, tells me that the single email address is precisly in compliance with RFC822? Jeez, now all I gotta do is figure out how the heck to get this function. Hopefully without being forced to swallow all of PEAR in one gulp, which was my last experience trying to use a PEAR class... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
On 3 Nov 2005, at 14:16, Richard Heyes wrote: It even has a method specifically for "normal" email addresses of the form [EMAIL PROTECTED] Ah, well, that's good news. It's been a while since I looked at it. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
Marcus Bointon wrote: The PEAR rfc822 class is pretty good, but it should be noted it's designed for parsing entire to, cc, bcc fields which may contain multiple addresses, and it's not quite as simple as asking it 'is this address ok'. News to me... if (!PEAR::isError(Mail_RFC822::parseAddressList('[EMAIL PROTECTED]'))) { // Valid... } It even has a method specifically for "normal" email addresses of the form [EMAIL PROTECTED] if (Mail_RFC822::isValidInetAddress('[EMAIL PROTECTED]')) { // Valid... } -- Richard Heyes http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
On 3 Nov 2005, at 04:32, viraj wrote: does PHP really needs a function to validate an email address!! i doubt. because PHP is a language which provides number of string functions with regex capabilities to develop what ever pattern matching you want. Writing a regex for RFC2822 is not easy - the format is extremely flexible. Having said that, I've got on very well using these: http://www.hexillion.com/samples/#Regex Though it doesn't deal with that oddity that Richard mentioned. The PEAR rfc822 class is pretty good, but it should be noted it's designed for parsing entire to, cc, bcc fields which may contain multiple addresses, and it's not quite as simple as asking it 'is this address ok'. second point is, different organizations have different policies on validating email addresses, so again those developers have to mend their own mechanisms. so everybody will not benefit this effort. Well, unless you're counting really different addressing standards like X.500, everyone has to operate within RFC2822. You're quite free to put additional constraints on addresses, but should be within that spec, not in addition to it. If an address is not RFC2822 compliant, it's pretty unlikely to work, though I have occasionally seen things like non-ASCII chars and '_' get through. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
Curt Zirzow wrote: On Wed, 02 Nov 2005 21:19:24 +0100, Jochem Maas wrote: I totally agree with Richard. about the need for a php func for checking a correct email addr. given that php 'is all about the web', idealogically (still?) pragmatic and dynamically typed: is_email_addr() or is_email() There already is: http://php.net/imap_rfc822_parse_adrlist http://pecl.php.net/mailparse And http://pear.php.net/Mail which has an Mail_RFC822 class for email address validation. -- Richard Heyes http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
On Thu, 03 Nov 2005 13:42:34 +1000, Ligaya Turmelle wrote: > >>There already is: >> http://php.net/imap_rfc822_parse_adrlist >> >> > quote from user contributed notes: > > "| This function does NOT test the syntax of either the local part, or the > host part, it will permit illegal characters on either side."| contributed notes are funny sometimes considering where local-part is defined as stuff before @ RFC822 local-part = word *("." word) ; uninterpreted ; case-preserved word= atom / quoted-string atom= 1* quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or ; quoted chars. qtext = , ; => may be folded "\" & CR, and including linear-white-space> quoted-pair = "\" CHAR ; may quote any char With his long example of what goes wrong it all comes down to the address that isn't validated properly: <@example.com:[EMAIL PROTECTED]> At first look this seems to be an odd email and one would think that it we are trying to send an email to: [EMAIL PROTECTED]:[EMAIL PROTECTED] which isn't valid but the key thing is the ':' in this address, it causes the address to really become [EMAIL PROTECTED] and the stuff before that is the 'phrase' of this address, I could bore you more on some more rfc definitions but i'll try to avoid that. I'll just mention that a phrase starts ends with a ':' and a phrase is allowed to have: phrase = 1*word ; Sequence of words And according to what word is defined as, @ isn't allowed, since it isn't quoted. So the statement that it doesn't validate local or host part is a wrong assumption, it has problems figuring out the phrase of the address. So yes does have a bug or two in address parsing, and i do wonder how often anyone even uses the phrase feature of email addresses anyway. Curt. -- http://news.zirzow.dyndns.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
On Thu, 2005-11-03 at 10:32 +0600, viraj wrote: > second point is, different organizations have different policies on > validating email addresses RFC822 Section 6.1 provides the standard (policy). -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
dear all, does PHP really needs a function to validate an email address!! i doubt. because PHP is a language which provides number of string functions with regex capabilities to develop what ever pattern matching you want. second point is, different organizations have different policies on validating email addresses, so again those developers have to mend their own mechanisms. so everybody will not benefit this effort. third point is, if we add another function to PHP which, bit off from the scope of a programming language someone else will request for some other function to validate a time format, time zone or family name(last name)!!, it will be a real mess!! just my two cents! if i have misinterpreted something please clear me. thanks. ~viraj On 11/3/05, Ligaya Turmelle <[EMAIL PROTECTED]> wrote: > > >There already is: > > http://php.net/imap_rfc822_parse_adrlist > > > > > quote from user contributed notes: > > "| This function does NOT test the syntax of either the local part, or > the host part, it will permit illegal characters on either side."| > > -- > Respectfully, > Ligaya Turmelle > > "Life is a game so have fun" > > -- > 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] Re: Richard Lynch's Email Address ...
There already is: http://php.net/imap_rfc822_parse_adrlist quote from user contributed notes: "| This function does NOT test the syntax of either the local part, or the host part, it will permit illegal characters on either side."| -- Respectfully, Ligaya Turmelle "Life is a game so have fun" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Richard Lynch's Email Address ...
On Wed, 02 Nov 2005 21:19:24 +0100, Jochem Maas wrote: > I totally agree with Richard. about the need for a php func for checking a > correct email addr. > > given that php 'is all about the web', idealogically (still?) pragmatic > and dynamically typed: > > is_email_addr() or is_email() There already is: http://php.net/imap_rfc822_parse_adrlist http://pecl.php.net/mailparse Curt. -- http://news.zirzow.dyndns.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Richard Lynch's Email Address ...
James Benson wrote: Would it not be better something like valid_email() sounds fine. call it what you like. :-) Reason: The is_* family check for a variable type so dont think that it really fits into the same catagory. twas a long shot ;-) James Jochem Maas wrote: I totally agree with Richard. about the need for a php func for checking a correct email addr. given that php 'is all about the web', idealogically (still?) pragmatic and dynamically typed: is_email_addr() or is_email() just 'belongs' with: is_array() is_bool() is_callable() is_double() is_float() is_int() is_integer() is_long() is_null() is_numeric() is_object() is_real() is_resource() is_scalar() is_string() any devs care to comment? kind regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Richard Lynch's Email Address ...
Would it not be better something like valid_email() Reason: The is_* family check for a variable type so dont think that it really fits into the same catagory. James Jochem Maas wrote: I totally agree with Richard. about the need for a php func for checking a correct email addr. given that php 'is all about the web', idealogically (still?) pragmatic and dynamically typed: is_email_addr() or is_email() just 'belongs' with: is_array() is_bool() is_callable() is_double() is_float() is_int() is_integer() is_long() is_null() is_numeric() is_object() is_real() is_resource() is_scalar() is_string() any devs care to comment? kind regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php