RE: [PHP] email validation string.

2007-01-20 Thread tedd

At 5:54 PM +0200 1/19/07, WeberSites LTD wrote:

Top Ajax :
I meant that at the top of WeberDev.com there is an Ajax search box that you
can use
to search for email validation and see many related code examples to
choose from.

berber


berber:

Your original post was clear enough for me to understand. Probably 
something else going on.


tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-20 Thread tedd

On Thu, Jan 18, 2007 at 01:40:36PM -0700, Don wrote:

 I'm trying to get this line to validate an email address from a form and it
 isn't working.

 if (ereg([EMAIL PROTECTED],$submittedEmail))




 The book I'm referencing has this line

 if (ereg([EMAIL PROTECTED],$submittedEmail))

 Anyway.. I welcome any advice as long as it doesn't morph into a political
 debate on ADA standards and poverty in Africa. :-)

 Thanks

 Don



Don:

I picked this up in my travels.

function validate_email($email)
{

   // Create the syntactical validation regular expression
   $regexp = 
^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$;


   // Presume that the email is invalid
   $valid = 0;

   // Validate the syntax
   if (eregi($regexp, $email))
   {
  list($username,$domaintld) = split(@,$email);
  // Validate the domain
  if (getmxrr($domaintld,$mxrecords))
 $valid = 1;
   } else {
  $valid = 0;
   }

   return $valid;

}

$email = [EMAIL PROTECTED];

if (validate_email($email))
   echo Email is valid!;
else
   echo Email is invalid!;

hth's

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-20 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-20 08:53:32 -0500:
 I picked this up in my travels.
 
 function validate_email($email)
 {
 
// Create the syntactical validation regular expression
$regexp = 
 ^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$;

One of my email addresses is
[EMAIL PROTECTED]

Also, [ ip-address ] is a valid right hand side of an email address,
e. g.:

[EMAIL PROTECTED]

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-20 Thread tedd

At 3:04 PM + 1/20/07, Roman Neuhauser wrote:

# [EMAIL PROTECTED] / 2007-01-20 08:53:32 -0500:

 I picked this up in my travels.

 function validate_email($email)
 {

// Create the syntactical validation regular expression
$regexp =
 ^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$;


One of my email addresses is
[EMAIL PROTECTED]



Thanks, I'll add that to my kill list.

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-20 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-20 09:22:00 -0500:
 At 3:04 PM + 1/20/07, Roman Neuhauser wrote:
 One of my email addresses is
 [EMAIL PROTECTED]
 
 Thanks, I'll add that to my kill list.

Vietnam vet... Old habits don't go away easily huh?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-20 Thread tedd

At 3:47 PM + 1/20/07, Roman Neuhauser wrote:

# [EMAIL PROTECTED] / 2007-01-20 09:22:00 -0500:

 At 3:04 PM + 1/20/07, Roman Neuhauser wrote:
 One of my email addresses is
 [EMAIL PROTECTED]

 Thanks, I'll add that to my kill list.


Vietnam vet... Old habits don't go away easily huh?


I didn't think of it that way, but that's a thought. Let's hope that 
you never run into a Vietnam vet who thinks that way (they do exist). 
As for me, I figure that you've never had any adversity to confront, 
so you just don't know any better -- however, I'm sure life 
experience and maturity will help you understand. Good luck with that.


tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] email validation string.

2007-01-19 Thread WeberSites LTD
Try this : http://www.weberdev.com/get_example-3274.html

berber 

-Original Message-
From: Don [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 18, 2007 10:41 PM
To: php-general@lists.php.net
Subject: [PHP] email validation string.

I'm trying to get this line to validate an email address from a form and it
isn't working.

if (ereg([EMAIL PROTECTED],$submittedEmail))

 

The book I'm referencing has this line

if (ereg([EMAIL PROTECTED],$submittedEmail))

 

Anyway.. I welcome any advice as long as it doesn't morph into a political
debate on ADA standards and poverty in Africa. :-)

 

Thanks

 

Don

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-19 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-19 10:55:21 +0200:
 From: Don [mailto:[EMAIL PROTECTED] 
  I'm trying to get this line to validate an email address from a form and it
  isn't working.
  
  if (ereg([EMAIL PROTECTED],$submittedEmail))
  
  The book I'm referencing has this line
  
  if (ereg([EMAIL PROTECTED],$submittedEmail))

1. Why did you remove the backslash? (the original was correct)
2. What do you expect the regexp to match?
3. Define it isn't working.
 
 Try this : http://www.weberdev.com/get_example-3274.html

This will reject addresses that use greylisting, and 600 lines
in a single function is gross.  I wouldn't touch that.
 
-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] email validation string.

2007-01-19 Thread WeberSites LTD
You can always go to http://www.weberdev.com/ and write email validation
in the Top Ajax search box. There are many other email validators that
should have less than 600 lines in one function :)

berber 

-Original Message-
From: Roman Neuhauser [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 19, 2007 12:17 PM
To: WeberSites LTD
Cc: 'Don'; php-general@lists.php.net
Subject: Re: [PHP] email validation string.

# [EMAIL PROTECTED] / 2007-01-19 10:55:21 +0200:
 From: Don [mailto:[EMAIL PROTECTED]
  I'm trying to get this line to validate an email address from a form 
  and it isn't working.
  
  if (ereg([EMAIL PROTECTED],$submittedEmail))
  
  The book I'm referencing has this line
  
  if (ereg([EMAIL PROTECTED],$submittedEmail))

1. Why did you remove the backslash? (the original was correct) 2. What do
you expect the regexp to match?
3. Define it isn't working.
 
 Try this : http://www.weberdev.com/get_example-3274.html

This will reject addresses that use greylisting, and 600 lines in a single
function is gross.  I wouldn't touch that.
 
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

--
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] email validation string.

2007-01-19 Thread 'Roman Neuhauser'
Don't top-post.
Trim quoted material.
Use a mail user agent that doesn't screw up quoting. There's a plugin
for Outlook to fix it.
Thanks.

# [EMAIL PROTECTED] / 2007-01-19 12:15:15 +0200:
 From: Roman Neuhauser [mailto:[EMAIL PROTECTED] 
  # [EMAIL PROTECTED] / 2007-01-19 10:55:21 +0200:
   Try this : http://www.weberdev.com/get_example-3274.html
  
  This will reject addresses that use greylisting, and 600 lines in a single
  function is gross.  I wouldn't touch that.
  
I should have also mentioned that the function is fundamentally flawed,
and the whole section dealing with deliverability should be removed.
The only way to reliably find out about an email address deliverability
is to send it a secret and receive it back (filtering out bounces).
This mathematician, Daniel Bernstein, has a proof-of-concept code in
ezmlm. :) (Or just google for VERP.)

 You can always go to http://www.weberdev.com/ and write email validation
 in the Top Ajax search box.

What's Top Ajax?

 There are many other email validators that should have less than 600
 lines in one function :)

I already have a regular expression that matches a reasonable subset of
the grammar defined in RFC 822.  Why should I use someone else's square
wheel when I have mine own? :)

Also, if there are many email validators with better code, please offer
those better ones if you must.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-19 Thread Nuno Oliveira


1. Why did you remove the backslash? (the original was correct)

I have a regular expression tester plugin in firefox and it validates Ok 
with the expression he provided.


If I add the second (original) backslash it won't validate emails anymore.

Also, from my little knowledge of Red.Exp. the backslash will escape special 
chars.
In this case the backslash will escape the dot to match only a dot and not 
all chars...


This my way of seing it...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-19 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-19 14:46:04 +:
 
 1. Why did you remove the backslash? (the original was correct)
 
 I have a regular expression tester plugin in firefox and it validates Ok 
 with the expression he provided.

JavaScript is *not* PHP.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-19 Thread Nuno Oliveira



1. Why did you remove the backslash? (the original was correct)


I have a regular expression tester plugin in firefox and it validates
Ok with the expression he provided.


JavaScript is *not* PHP.



As far as I can read, I never talked about JavaScript...
Maybe the fact that I talked about a browser made you think I was
using Java.

NO! I'm not. This is a php list and I gave my answer based on that.
This plugin I was talking about uses PHP/5.2.0

In either case... Aren't both expressions supposed to validate
an e-mail??

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] email validation string.

2007-01-19 Thread WeberSites LTD
Top Ajax : 
I meant that at the top of WeberDev.com there is an Ajax search box that you
can use
to search for email validation and see many related code examples to
choose from.

berber 

-Original Message-
From: 'Roman Neuhauser' [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 19, 2007 1:47 PM
To: WeberSites LTD
Cc: 'Don'; php-general@lists.php.net
Subject: Re: [PHP] email validation string.

Don't top-post.
Trim quoted material.
Use a mail user agent that doesn't screw up quoting. There's a plugin for
Outlook to fix it.
Thanks.

# [EMAIL PROTECTED] / 2007-01-19 12:15:15 +0200:
 From: Roman Neuhauser [mailto:[EMAIL PROTECTED]
  # [EMAIL PROTECTED] / 2007-01-19 10:55:21 +0200:
   Try this : http://www.weberdev.com/get_example-3274.html
  
  This will reject addresses that use greylisting, and 600 lines in a 
  single function is gross.  I wouldn't touch that.
  
I should have also mentioned that the function is fundamentally flawed, and
the whole section dealing with deliverability should be removed.
The only way to reliably find out about an email address deliverability is
to send it a secret and receive it back (filtering out bounces).
This mathematician, Daniel Bernstein, has a proof-of-concept code in ezmlm.
:) (Or just google for VERP.)

 You can always go to http://www.weberdev.com/ and write email validation
 in the Top Ajax search box.

What's Top Ajax?

 There are many other email validators that should have less than 600 
 lines in one function :)

I already have a regular expression that matches a reasonable subset of the
grammar defined in RFC 822.  Why should I use someone else's square wheel
when I have mine own? :)

Also, if there are many email validators with better code, please offer
those better ones if you must.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] email validation string.

2007-01-19 Thread bruce
hi...

the real problem you have with email validation is that the vast majority of
the email validation scripts that you see in various apps only handle a part
of what the wc3/spec states to be valid email addresses.

if your app had the ability to handle the time constraint, a reasonable
approach would be to simply fire off a msg to the email address and check
the return status code! if you're really going to try to get a function to
validate email addresses, and you're concerned about the outlying address
types, then you're going to wind up with an ugly/hairy/complex situation.

awhile ago, in taking the path least traveled, i punted this issue, and used
a 'perl' function that i call from php to handle it... does it take a little
longer, sure... but i decided it was worth it


peace..



-Original Message-
From: Roman Neuhauser [mailto:[EMAIL PROTECTED]
Sent: Friday, January 19, 2007 2:17 AM
To: WeberSites LTD
Cc: 'Don'; php-general@lists.php.net
Subject: Re: [PHP] email validation string.


# [EMAIL PROTECTED] / 2007-01-19 10:55:21 +0200:
 From: Don [mailto:[EMAIL PROTECTED]
  I'm trying to get this line to validate an email address from a form and
it
  isn't working.
 
  if (ereg([EMAIL PROTECTED],$submittedEmail))
 
  The book I'm referencing has this line
 
  if (ereg([EMAIL PROTECTED],$submittedEmail))

1. Why did you remove the backslash? (the original was correct)
2. What do you expect the regexp to match?
3. Define it isn't working.

 Try this : http://www.weberdev.com/get_example-3274.html

This will reject addresses that use greylisting, and 600 lines
in a single function is gross.  I wouldn't touch that.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

--
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] email validation string.

2007-01-19 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-19 15:43:32 +:
 
 1. Why did you remove the backslash? (the original was correct)
 
 I have a regular expression tester plugin in firefox and it validates
 Ok with the expression he provided.
 
 JavaScript is *not* PHP.
 
 As far as I can read, I never talked about JavaScript...
 Maybe the fact that I talked about a browser made you think I was
 using Java.  NO! I'm not. This is a php list and I gave my answer
 based on that.  This plugin I was talking about uses PHP/5.2.0
 
JavaScript is *not* Java. ;) But ok, sorry about the assumption.
Where can I check out the plugin?
 
 In either case... Aren't both expressions supposed to validate
 an e-mail??

PHP uses one of two sets of special characters depending on whether you
use single or double quotes, and leaves a single backslash preceeding a
non-special character intact.  PCRE removes backslashes if they're
followed by non-special characters (but see /X).

IOW, as opposed to PHP, PCRE will reduce \x to x for any x that's not
special.  Use \\x if you want \x.
PHP will, however, reduce \\x to \x, since \ is special.

Relying on PHP's behavior with ordinary-x \x in a PCRE introduces
another grammar to the mix.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-19 Thread Nuno Oliveira

Where can I check out the plugin?


Maybe I shouldn't have mentioned plugin and firefox...

It's not a plugin for firefox like other firefox's plugins...
In fact, when I downloaded somewhere arround the web
the name of the thing (won't call it plugin again) was
Site Programmer Plugin Assistant (or something alike)
and it's just a bunch of php scripts that run as a local
site...

That's why I said that the plugin was using PHP/5.2.0
because that's the php version I have installed.

It needs Apache with PHP support to work and the php
code it uses is a form that processes a text field and do
a ereg($Pattern, $Text) on an if statment that outputs
Match or No Match. Meaning pure PHP (in my case
v5.2.0)

For a real Firefox plugin that shows the matched part
of the text in real time as you change the pattern, you
can search for a plugin (a real one) named Regular
Expressions Tester. I don't have it but you can search
http://www.mozilla.com for it.
Wait... https://addons.mozilla.org/firefox/2077/ this is
the homepage for the plugin.
However, I don't know if this uses Java(script) or what...

About what I asked in my last post... In php, if you have
a string like $Text=[a-zA-Z]+\\. php will save it like
[a-zA-Z]+\. because the first backslash is escaping a
special character which is the second backslash but if
you have the string $Text=[a-zA-Z]+\. php will save it
the exactly the same way because even that the backslash
is used to escape special characters, there is no special
char after it. It's just a dot. So the string gets stored the
same way. Also it doesn't get different with quotes or
double quotes.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-18 Thread Nick Stinemates
I just got this from: http://php.net/preg_match

?php
if(eregi (^[[:alnum:[EMAIL PROTECTED],6}$, stripslashes(trim($someVar
{
  echo good;
}
else
{
  echo bad;
}
?


Hope it works out for you.
 - Nick Stinemates

On Thu, Jan 18, 2007 at 01:40:36PM -0700, Don wrote:
 I'm trying to get this line to validate an email address from a form and it
 isn't working.
 
 if (ereg([EMAIL PROTECTED],$submittedEmail))
 
  
 
 The book I'm referencing has this line
 
 if (ereg([EMAIL PROTECTED],$submittedEmail))
 
  
 
 Anyway.. I welcome any advice as long as it doesn't morph into a political
 debate on ADA standards and poverty in Africa. :-)
 
  
 
 Thanks
 
  
 
 Don
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation string.

2007-01-18 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-18 06:07:24 -0800:
 I just got this from: http://php.net/preg_match
 
 ?php
 if(eregi (^[[:alnum:[EMAIL PROTECTED],6}$, stripslashes(trim($someVar

That would reject many of my email addresses.  This is more in line with
the standards:

http://marc.theaimsgroup.com/?l=postgresql-generalm=112612299412819w=2

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] email validation (no regex)

2005-09-21 Thread Michael Sims
Jim Moseby wrote:
 There's no requirement for an MX-record, so you'd need to check the
 A-record ($domain) too.

 Excellent answer.  No requirement for MX record?

 [showing my ignorance]
 How does email routing happen if there is no mail exchanger in the
 zonefile for a particular domain?
 [/ignorance]

Most all mail transfer agents will fall back to looking for an A record if an MX
record doesn't exist.  It's good practice to define an MX record but it isn't
required...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation (no regex)

2005-09-21 Thread cron


As an admin I would assume this as spammers trying to get some emails and I 
would block this on the firewall.



- Original Message - 
From: Michael Sims [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Wednesday, September 21, 2005 4:22 PM
Subject: RE: [PHP] email validation (no regex)



Jim Moseby wrote:

There's no requirement for an MX-record, so you'd need to check the
A-record ($domain) too.


Excellent answer.  No requirement for MX record?

[showing my ignorance]
How does email routing happen if there is no mail exchanger in the
zonefile for a particular domain?
[/ignorance]


Most all mail transfer agents will fall back to looking for an A record if 
an MX
record doesn't exist.  It's good practice to define an MX record but it 
isn't

required...

--
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] email validation regex

2005-09-16 Thread Kevin Waterson
This one time, at band camp, bruce [EMAIL PROTECTED] wrote:

 hi..
 
 looking for a good/working/tested php email validation regex that conforms
 to the rfc2822 standard.

This will be fun, everybody has their own which is always best. No two people
will agree what is correct method and will always come with a 'better' one.
This is generally accompanied by derision and ridicule of the others.
To this end, I will start the ball rolling with this one...

preg_match('/[EMAIL PROTECTED],}\.[\w]{2,6}$/iU', $email)


Kevin
-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] email validation regex

2005-09-16 Thread bruce
perl has a mod email::valid that claims to do email validation, and it
appears to be fairly complex/lengthy.

i'm considering simply using this in a perl app, that i'd then call from the
php function...

use the best tool for the job in the quickest manner!!!

thoughts

-bruce


-Original Message-
From: Kevin Waterson [mailto:[EMAIL PROTECTED]
Sent: Friday, September 16, 2005 8:08 AM
To: php-general@lists.php.net
Subject: Re: [PHP] email validation regex


This one time, at band camp, bruce [EMAIL PROTECTED] wrote:

 hi..

 looking for a good/working/tested php email validation regex that conforms
 to the rfc2822 standard.

This will be fun, everybody has their own which is always best. No two
people
will agree what is correct method and will always come with a 'better' one.
This is generally accompanied by derision and ridicule of the others.
To this end, I will start the ball rolling with this one...

preg_match('/[EMAIL PROTECTED],}\.[\w]{2,6}$/iU', $email)


Kevin
--
Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote.

--
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] email validation regex

2005-09-16 Thread Nuno Pereira

bruce wrote:

hi..

looking for a good/working/tested php email validation regex that conforms
to the rfc2822 standard.

a lot of what i've seen from google breaks, or doesn't follow the standard!

any ideas/thoughts/sample code/etc...


I use this code to build the regex

$tld='[a-z]{2,}';
$regexp='^([_a-z0-9-]+)(\.[_a-z0-9-]+)*'.
'@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.'.$tld.')$';

And test it like this:

/* BEGIN PHP code*/
if (eregi($regexp, $email))
{
list($username,$domaintld) = split(@,$email);
// Validate domain
if (getmxrr($domaintld,$mxrecords)) {
$valid = true;
/*print(Domain: $domaintldbr /);
foreach($mxrecords as $mxKey = $mxValue)
print(nbsp;nbsp;$mxValuebr /);*/
} else {
if (checkdnsrr($domaintld, any))
$valid=true;
else
$errors.=The domain ('$domaintld') is 
invalid..
 Please check the email.br /;
}
} else {
$errors.=The email ('$email') isn't valid.br /;
$valid = false;
}
/* END PHP code*/

I used to get TLD list from 
http://data.iana.org/TLD/tlds-alpha-by-domain.txt


Replacing the above TLD with

/*$tld = 
'(AC|AD|AE|AERO|AF|AG|AI|AL|AM|AN|AO|AQ|AR|ARPA|AS|AT|AU|AW|AZ|'. 
'BA|BB|BD|BE|BF|BG|BH|BI|BIZ|BJ|BM|BN|BO|BR|BS|BT|BV|BW|BY|BZ|CA|CC|'.	'CD|CF|CG|CH|CI|CK|CL|CM|CN|CO|COM|COOP|CR|CU|CV|CX|CY|CZ|DE|DJ|DK|DM'. 
'|DO|DZ|EC|EDU|EE|EG|ER|ES|ET|EU|FI|FJ|FK|FM|FO|FR|GA|GB|GD|GE|GF|GG|GH|'. 
'GI|GL|GM|GN|GOV|GP|GQ|GR|GS|GT|GU|GW|GY|HK|HM|HN|HR|HT|HU|ID|IE|IL|'.	'IM|IN|INFO|INT|IO|IQ|IR|IS|IT|JE|JM|JO|JP|KE|KG|KH|KI|KM|KN|KR|KW|KY'. 
'|KZ|LA|LB|LC|LI|LK|LR|LS|LT|LU|LV|LY|MA|MC|MD|MG|MH|MIL|MK|ML|MM|MN|'.	'MO|MP|MQ|MR|MS|MT|MU|MUSEUM|MV|MW|MX|MY|MZ|NA|NAME|NC|NE|NET|NF|NG|'. 
'NI|NL|NO|NP|NR|NU|NZ|OM|ORG|PA|PE|PF|PG|PH|PK|PL|PM|PN|PR|PRO|PS|PT|'.	'PW|PY|QA|RE|RO|RU|RW|SA|SB|SC|SD|SE|SG|SH|SI|SJ|SK|SL|SM|SN|SO|SR|ST'. 
'|SU|SV|SY|SZ|TC|TD|TF|TG|TH|TJ|TK|TL|TM|TN|TO|TP|TR|TT|TV|TW|TZ|UA|'. 
'UG|UK|UM|US|UY|UZ|VA|VC|VE|VG|VI|VN|VU|WF|WS|YE|YT|YU|ZA|ZM|ZW)';

*/

But as I check if the email domain part is exists, this is not needed.

This is fairly good, and is adapted from a page that i don't have here 
the reference. I think that it is RFC compatible in the regex, cause I 
remember to see it to build the regex. The domain check code is adapted 
as the in the original code it only checks for MX records, but in the 
RFC says that if no MX records exist (where he should deliver), try to 
deliver to the machine, e.g., if no mail.isp.com MX records exist, try 
to deliver the message to the mail.isp.com machine (with SMTP, obviously).


PS: your Perl solution can be good, but I think that there exist PHP 
classes that do it, but I don't know one.

--
Nuno Pereira

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation regex

2005-09-16 Thread John Nichel

bruce wrote:

hi..

looking for a good/working/tested php email validation regex that conforms
to the rfc2822 standard.

a lot of what i've seen from google breaks, or doesn't follow the standard!

any ideas/thoughts/sample code/etc...


Didn't we just have this flame war about a month ago?  Is it time for it 
to come up again?  Top posting must be right around the corner; damn, I 
love this time of year. ;)


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email validation regex

2005-09-16 Thread Jordan Miller

What do you mean? What's wrong with top posting? ;)

Jordan


On Sep 16, 2005, at 11:31 AM, John Nichel wrote:


bruce wrote:


hi..
looking for a good/working/tested php email validation regex that  
conforms

to the rfc2822 standard.
a lot of what i've seen from google breaks, or doesn't follow the  
standard!

any ideas/thoughts/sample code/etc...



Didn't we just have this flame war about a month ago?  Is it time  
for it to come up again?  Top posting must be right around the  
corner; damn, I love this time of year. ;)


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
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] email validation regex

2005-09-16 Thread John Nichel

Jordan Miller wrote:

What do you mean? What's wrong with top posting? ;)


The bait is on the hook..

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] email validation regex

2005-09-16 Thread bruce
reel 'em in john

but remember.. there's top/bottom/side/spoon/etc for more, head to san
francisco!!

later..

-Original Message-
From: John Nichel [mailto:[EMAIL PROTECTED]
Sent: Friday, September 16, 2005 10:19 AM
To: php-general@lists.php.net
Subject: Re: [PHP] email validation regex


Jordan Miller wrote:
 What do you mean? What's wrong with top posting? ;)

The bait is on the hook..

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
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] Email validation

2002-06-12 Thread Justin French

There is a great function library on http://killersoft.com/ which was
derived from what is widely considered the best email validation script in
Perl.

It also follows RFC 822 about as close as is possible.
[http://www.faqs.org/rfcs/rfc822.html]

I was about to start writing something simular, but decided not to re-invent
the wheel... I've adopted this script on every project from now on, thanks
to the kind person on this list who let me know about it!


Justin French


on 13/06/02 2:56 AM, Jeroen Timmers ([EMAIL PROTECTED]) wrote:

 Is there a simple function that validate an email adres
 
 Thx
 
 Jeroen Timmers
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Email validation

2001-03-25 Thread Manuel Lemos

Hello Mike,

On 21-Mar-01 01:21:13, you wrote:

Hello Again,

Can anyone tell me what the best form of Email validation there is?  It needs
to be quick  as open to - and . as possible.

Look here for a complete email validation class:

http://phpclasses.UpperDesign.com/browse.html/package/13

Regards,
Manuel Lemos

Web Programming Components using PHP Classes.
Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
--
E-mail: [EMAIL PROTECTED]
URL: http://www.mlemos.e-na.net/
PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
--


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Email validation

2001-03-20 Thread Jason Murray

 Can anyone tell me what the best form of Email validation 
 there is?  It needs to be quick  as open to - and . as possible.

We use this one on www.inww.com:

?
   Function validEmail($emailaddress)
   { 
 // Decides if the email address is valid. Checks syntax and MX records,
 // for total smartass value. Returns "valid", "invalid-mx" or 
 // "invalid-form".
   
 // Validates the email address. I guess it works. *shrug*
 if
(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",
$emailaddress, $check))
 {
   //if ( getmxrr(substr(strstr($check[0], '@'), 1),
$validate_email_temp) ) 
   if ( checkdnsrr(substr(strstr($check[0], '@'), 1), "ANY") ) 
   { return "valid"; }
   else
   { return "invalid-mx"; } 
 }
 else
 {
   return "invalid-form"; 
 }
   }
?

Jason

-- 
Jason Murray
[EMAIL PROTECTED]
Web Design Team, Melbourne IT
Fetch the comfy chair!


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]