Re: [PHP] Re: Richard Lynch's Email Address ...

2005-11-09 Thread GamblerZG

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 ...

2005-11-08 Thread Richard Lynch
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 ...

2005-11-03 Thread Richard Heyes

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 ...

2005-11-03 Thread Marcus Bointon

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 ...

2005-11-03 Thread Richard Heyes

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 ...

2005-11-03 Thread Marcus Bointon

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 ...

2005-11-02 Thread Jochem Maas

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



Re: [PHP] Re: Richard Lynch's Email Address ...

2005-11-02 Thread Ligaya Turmelle



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



Re: [PHP] Re: Richard Lynch's Email Address ...

2005-11-02 Thread viraj
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 ...

2005-11-02 Thread Greg Donald
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 ...

2005-11-02 Thread Curt Zirzow
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*any CHAR except specials, SPACE and CTLs
 quoted-string =  *(qtext/quoted-pair) ; Regular qtext or
 ;   quoted chars. 
 qtext   =  any CHAR excepting , ; = 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