转载:邮箱正则表达式Comparing E-mail Address Validating Regular Expressions

Comparing E-mail Address Validating Regular Expressions

Updated: 2/3/2012

Summary

This page compares regular expressions that validate e-mail addresses in order to find the best one. The expression with the best score is currently the one used by PHP's filter_var(), which is based on a regex by Michael Rushton:

/^(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){65,}@)(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22))(?:\.(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\]))$/iD

The best one that's been verified to work in JavaScript is Arluison Guillaume's improvement of Warren Gaebel's regex:

/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i

Introduction

I was writing a web application and wanted to find a regular expression to validate user's e-mail addresses, but when I searched for one I found dozens of slightly different variations of the same expression. Almost all of the posts were followed by comments describing examples of false-positives or false-negatives. But dispite all the criticism, I couldn't find a definitive "best" expression. So, I setup arrays of some of the most promising ones to run against a set of known valid and invalid addresses. I think that it's better to accept a few invalid addresses than reject any valid ones, so I'm shooting for 0 false-negatives and as few false-positives as possible.

It's been about 5 years since I initially created this, and I think we've found a relatively solid answer, but if you know of an expression that tests better than the current one, or if you have some other feedback feel free to contact me. If you feel think that any of the addresses are incorrectly labeled, please take it up with Cal Henderson or Dominic Sayers, since I've used their test data.

Notes

  • There's no perfect regular expression to validate e-mail addresses
  • If you need something more advanced than a simple regex, check out RFC 822/2822/5322 Email Address Parser in PHP or is_email() Address Validation.
  • I think it's better to allow any TLD, even if it doesn't exist, than to put a static list of currently-existing TLDs into the regex. The problem with a static list is that the regex will be used in production environments, but probably won't be updated when new TLDs come out.
  • Some of these are dependent on being executed using case-insenstive regex functions.
  • This page uses PHP's ereg() and preg_match() functions, but some of these will work with JavaScript and other languages
  • These regex's only check if the address is syntactically valid. It's entirely possible that an address which does not exist on any mail server would pass this test. Checking to see if an address actually exists isn't always practical or necessary, though.
  • Slow regex's can be a security risk.
  • Remember the Robustness Principle when handling addresses that fail to validate.
  • Some of the test addresses below are very long, and have been truncated for displaying.

Detailed Results

/^(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){65,}@)(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22))(?:\.(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\]))$/iD

http://svn.php.net/viewvc/php/php-src/trunk/ext/filter/logical_filters.c?view=markup
Uses preg_match()
These should be valid
[email protected] valid
1234567890123456789012345678901234567890123456789012345678901234@iana.org valid
"first\"last"@iana.org valid
"first@last"@iana.org valid
"first\last"@iana.org valid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] valid
1234567890123456789012345678901234567890123456789012345678@1234567890123456789012345678901234567890123456 [...] valid
first.last@[12.34.56.78] valid
first.last@[IPv6:::12.34.56.78] valid
first.last@[IPv6:1111:2222:3333::4444:12.34.56.78] valid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78] valid
first.last@[IPv6:::1111:2222:3333:4444:5555:6666] valid
first.last@[IPv6:1111:2222:3333::4444:5555:6666] valid
first.last@[IPv6:1111:2222:3333:4444:5555:6666::] valid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888] valid
first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org valid
[email protected] valid
[email protected] valid
"first\last"@iana.org valid
first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777] invalid
[email protected] invalid
first.last@com invalid
"Abc\@def"@iana.org valid
"Fred\ Bloggs"@iana.org valid
"Joe.\Blow"@iana.org valid
"Abc@def"@iana.org valid
"Fred Bloggs"@iana.org invalid
[email protected] valid
customer/[email protected] valid
[email protected] valid
!def!xyz%[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug \"Ace\" L."@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
t*[email protected] valid
[email protected] valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org invalid
[email protected] valid
"test.test"@iana.org valid
test."test"@iana.org valid
"test@test"@iana.org valid
[email protected] valid
[email protected] invalid
test@[123.123.123.123] valid
[email protected] valid
[email protected] valid
"test\test"@iana.org valid
test@example invalid
"test\blah"@iana.org valid
"test\blah"@iana.org valid
"test\"blah"@iana.org valid
customer/[email protected] valid
[email protected] valid
[email protected] valid
"Austin@Powers"@iana.org valid
[email protected] valid
"Ima.Fool"@iana.org valid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org valid
"first".middle."last"@iana.org valid
"first"[email protected] valid
first."last"@iana.org valid
"first"."middle"."last"@iana.org valid
"first.middle"."last"@iana.org valid
"first.middle.last"@iana.org valid
"first..last"@iana.org valid
"first\\\"last"@iana.org valid
first."mid\dle"."last"@iana.org valid
"test blah"@iana.org invalid
(foo)cal(bar)@(baz)iamcal.com(quux) invalid
cal@iamcal(woo).(yay)com invalid
cal(woo(yay)hoopla)@iamcal.com invalid
cal(foo\@bar)@iamcal.com invalid
cal(foo\)bar)@iamcal.com invalid
first()[email protected] invalid
pete(his account)@silly.test(his host) invalid
c@(Chris's host.)public.example invalid
jdoe@machine(comment). example invalid
1234 @ local(blah) .machine .example invalid
first(abc.def)[email protected] invalid
first(a"bc.def)[email protected] invalid
first.(")middle.last(")@iana.org invalid
first(abc\(def)@iana.org invalid
first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com invalid
a(a(b(c)d(e(f))g)h(i)j)@iana.org invalid
[email protected] valid
a@b invalid
[email protected] valid
aaa@[123.123.123.123] valid
a@bar invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] invalid
"Joe\Blow"@iana.org valid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%[email protected] valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|[email protected] valid
first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::] invalid
first.last@[IPv6:::] valid
first.last@[IPv6:::b4] valid
first.last@[IPv6:::b3:b4] valid
first.last@[IPv6:a1::b4] valid
first.last@[IPv6:a1::] valid
first.last@[IPv6:a1:a2::] valid
first.last@[IPv6:0123:4567:89ab:cdef::] valid
first.last@[IPv6:0123:4567:89ab:CDEF::] valid
first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44] valid
first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4::11.22.33.44] valid
first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33.44] valid
first.last@[IPv6:a1:a2::11.22.33.44] valid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44] valid
first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44] valid
first.last@[IPv6:a1::b2:11.22.33.44] valid
[email protected] valid
[email protected] valid
[email protected] valid
 
These should be invalid
[email protected],com invalid
first\@[email protected] invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] invalid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org valid
first\@[email protected] invalid
first.last@ invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
first.last@[.12.34.56.78] invalid
first.last@[12.34.56.789] invalid
first.last@[::12.34.56.78] invalid
first.last@[IPv5:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999] invalid
first.last@[IPv6:1111:2222::3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:333x::4444:5555] invalid
first.last@[IPv6:1111:2222:33333::4444:5555] invalid
[email protected] invalid
[email protected] invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org invalid
abc\@[email protected] invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ [email protected] invalid
abc@[email protected] invalid
abc\@[email protected] invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"[email protected] invalid
ote"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\[email protected] invalid
hello [email protected] invalid
[email protected]. invalid
test.iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
test@[email protected] invalid
test@@iana.org invalid
-- test [email protected] invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
[email protected] invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] invalid
test@[123.123.123.123 invalid
[email protected]] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
Ima [email protected] invalid
phil.h\@\@[email protected] invalid
foo@[\1.2.3.4] invalid
first.""[email protected] valid
first\[email protected] invalid
Abc\@[email protected] invalid
Fred\ [email protected] invalid
Joe.\[email protected] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89] invalid
{^c\@**Dog^}@cartoon.com invalid
"foo"(yay)@(hoopla)[1.2.3.4] invalid
cal(foo(bar)@iamcal.com invalid
cal(foo)bar)@iamcal.com invalid
cal(foo\)@iamcal.com invalid
first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012 [...] invalid
first(middle)[email protected] invalid
first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno). [...] invalid
a(a(b(c)d(e(f))g)(h(i)j)@iana.org invalid
.@ invalid
@bar.com invalid
@@bar.com invalid
aaa.com invalid
[email protected] invalid
[email protected] invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
[email protected]. invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Unicode NULL "@char.com invalid
Unicode NULL @char.com invalid
first.last@[IPv6::] invalid
first.last@[IPv6::::] invalid
first.last@[IPv6::b4] invalid
first.last@[IPv6::::b4] invalid
first.last@[IPv6::b3:b4] invalid
first.last@[IPv6::::b3:b4] invalid
first.last@[IPv6:a1:::b4] invalid
first.last@[IPv6:a1:] invalid
first.last@[IPv6:a1:::] invalid
first.last@[IPv6:a1:a2:] invalid
first.last@[IPv6:a1:a2:::] invalid
first.last@[IPv6::11.22.33.44] invalid
first.last@[IPv6::::11.22.33.44] invalid
first.last@[IPv6:a1:11.22.33.44] invalid
first.last@[IPv6:a1:::11.22.33.44] invalid
first.last@[IPv6:a1:a2:::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.xx] invalid
first.last@[IPv6:0123:4567:89ab:CDEFF::11.22.33.44] invalid
first.last@[IPv6:a1::a4:b1::b4:11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33] invalid
first.last@[IPv6:a1::11.22.33.44.55] invalid
first.last@[IPv6:a1::b211.22.33.44] invalid
first.last@[IPv6:a1::b2::11.22.33.44] invalid
first.last@[IPv6:a1::b3:] invalid
first.last@[IPv6::a2::b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3:] invalid
first.last@[IPv6::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4::b1:b2:b3:b4] invalid

Valid: 96/134
Invalid: 130/132

/^(?:(?:(?:[^@,"\[\]\x5c\x00-\x20\x7f-\xff\.]|\x5c(?=[@,"\[\]\x5c\x00-\x20\x7f-\xff]))(?:[^@,"\[\]\x5c\x00-\x20\x7f-\xff\.]|(?<=\x5c)[@,"\[\]\x5c\x00-\x20\x7f-\xff]|\x5c(?=[@,"\[\]\x5c\x00-\x20\x7f-\xff])|\.(?=[^\.])){1,62}(?:[^@,"\[\]\x5c\x00-\x20\x7f-\xff\.]|(?<=\x5c)[@,"\[\]\x5c\x00-\x20\x7f-\xff])|[^@,"\[\]\x5c\x00-\x20\x7f-\xff\.]{1,2})|"(?:[^"]|(?<=\x5c)"){1,62}")@(?:(?!.{64})(?:[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.?|[a-zA-Z0-9]\.?)+\.(?:xn--[a-zA-Z0-9]+|[a-zA-Z]{2,6})|\[(?:[0-1]?\d?\d|2[0-4]\d|25[0-5])(?:\.(?:[0-1]?\d?\d|2[0-4]\d|25[0-5])){3}\])$/

http://jgotti.net/
Uses preg_match()
These should be valid
[email protected] valid
1234567890123456789012345678901234567890123456789012345678901234@iana.org valid
"first\"last"@iana.org valid
"first@last"@iana.org valid
"first\last"@iana.org valid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
1234567890123456789012345678901234567890123456789012345678@1234567890123456789012345678901234567890123456 [...] invalid
first.last@[12.34.56.78] valid
first.last@[IPv6:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78] invalid
first.last@[IPv6:::1111:2222:3333:4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666::] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888] invalid
first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org invalid
[email protected] valid
[email protected] valid
"first\last"@iana.org valid
first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777] invalid
[email protected] invalid
first.last@com invalid
"Abc\@def"@iana.org valid
"Fred\ Bloggs"@iana.org valid
"Joe.\Blow"@iana.org valid
"Abc@def"@iana.org valid
"Fred Bloggs"@iana.org valid
[email protected] valid
customer/[email protected] valid
[email protected] valid
!def!xyz%[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug \"Ace\" L."@iana.org valid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
t*[email protected] valid
[email protected] valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org valid
[email protected] valid
"test.test"@iana.org valid
test."test"@iana.org invalid
"test@test"@iana.org valid
[email protected] invalid
[email protected] invalid
test@[123.123.123.123] valid
[email protected] valid
[email protected] valid
"test\test"@iana.org valid
test@example invalid
"test\blah"@iana.org valid
"test\blah"@iana.org valid
"test\"blah"@iana.org valid
customer/[email protected] valid
[email protected] valid
[email protected] valid
"Austin@Powers"@iana.org valid
[email protected] valid
"Ima.Fool"@iana.org valid
"Ima Fool"@iana.org valid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first"[email protected] invalid
first."last"@iana.org invalid
"first"."middle"."last"@iana.org invalid
"first.middle"."last"@iana.org invalid
"first.middle.last"@iana.org valid
"first..last"@iana.org valid
"first\\\"last"@iana.org valid
first."mid\dle"."last"@iana.org invalid
"test blah"@iana.org valid
(foo)cal(bar)@(baz)iamcal.com(quux) invalid
cal@iamcal(woo).(yay)com invalid
cal(woo(yay)hoopla)@iamcal.com valid
cal(foo\@bar)@iamcal.com valid
cal(foo\)bar)@iamcal.com invalid
first()[email protected] valid
pete(his account)@silly.test(his host) invalid
c@(Chris's host.)public.example invalid
jdoe@machine(comment). example invalid
1234 @ local(blah) .machine .example invalid
first(abc.def)[email protected] valid
first(a"bc.def)[email protected] invalid
first.(")middle.last(")@iana.org invalid
first(abc\(def)@iana.org invalid
first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com invalid
a(a(b(c)d(e(f))g)h(i)j)@iana.org valid
[email protected] valid
a@b invalid
[email protected] valid
aaa@[123.123.123.123] valid
a@bar invalid
[email protected] valid
[email protected] invalid
[email protected] valid
[email protected] valid
"hello my name is"@stutter.com valid
"Test \"Fail\" Ing"@iana.org valid
[email protected] valid
[email protected] invalid
[email protected] invalid
"Joe\Blow"@iana.org valid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%[email protected] valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|[email protected] valid
first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::] invalid
first.last@[IPv6:::] invalid
first.last@[IPv6:::b4] invalid
first.last@[IPv6:::b3:b4] invalid
first.last@[IPv6:a1::b4] invalid
first.last@[IPv6:a1::] invalid
first.last@[IPv6:a1:a2::] invalid
first.last@[IPv6:0123:4567:89ab:cdef::] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::] invalid
first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4::11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33.44] invalid
first.last@[IPv6:a1:a2::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44] invalid
first.last@[IPv6:a1::b2:11.22.33.44] invalid
[email protected] valid
[email protected] valid
[email protected] valid
 
These should be invalid
[email protected],com invalid
first\@[email protected] valid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] invalid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org valid
""@iana.org invalid
first\@[email protected] valid
first.last@ invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
first.last@[.12.34.56.78] invalid
first.last@[12.34.56.789] invalid
first.last@[::12.34.56.78] invalid
first.last@[IPv5:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999] invalid
first.last@[IPv6:1111:2222::3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:333x::4444:5555] invalid
first.last@[IPv6:1111:2222:33333::4444:5555] invalid
[email protected] invalid
[email protected] invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org invalid
abc\@[email protected] valid
abc\@iana.org invalid
Doug\ \"Ace\"\ [email protected] valid
abc@[email protected] invalid
abc\@[email protected] valid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"[email protected] invalid
ote"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\[email protected] invalid
hello [email protected] invalid
[email protected]. invalid
test.iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
test@[email protected] invalid
test@@iana.org invalid
-- test [email protected] invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
[email protected] invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] invalid
test@[123.123.123.123 invalid
[email protected]] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
Ima [email protected] invalid
phil.h\@\@[email protected] valid
foo@[\1.2.3.4] invalid
first.""[email protected] invalid
first\[email protected] invalid
Abc\@[email protected] valid
Fred\ [email protected] valid
Joe.\[email protected] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89] invalid
{^c\@**Dog^}@cartoon.com valid
"foo"(yay)@(hoopla)[1.2.3.4] invalid
cal(foo(bar)@iamcal.com valid
cal(foo)bar)@iamcal.com valid
cal(foo\)@iamcal.com invalid
first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012 [...] invalid
first(middle)[email protected] valid
first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno). [...] invalid
a(a(b(c)d(e(f))g)(h(i)j)@iana.org valid
.@ invalid
@bar.com invalid
@@bar.com invalid
aaa.com invalid
[email protected] invalid
[email protected] invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
[email protected]. invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] valid
[email protected] invalid
[email protected] invalid
"Unicode NULL "@char.com valid
Unicode NULL @char.com invalid
first.last@[IPv6::] invalid
first.last@[IPv6::::] invalid
first.last@[IPv6::b4] invalid
first.last@[IPv6::::b4] invalid
first.last@[IPv6::b3:b4] invalid
first.last@[IPv6::::b3:b4] invalid
first.last@[IPv6:a1:::b4] invalid
first.last@[IPv6:a1:] invalid
first.last@[IPv6:a1:::] invalid
first.last@[IPv6:a1:a2:] invalid
first.last@[IPv6:a1:a2:::] invalid
first.last@[IPv6::11.22.33.44] invalid
first.last@[IPv6::::11.22.33.44] invalid
first.last@[IPv6:a1:11.22.33.44] invalid
first.last@[IPv6:a1:::11.22.33.44] invalid
first.last@[IPv6:a1:a2:::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.xx] invalid
first.last@[IPv6:0123:4567:89ab:CDEFF::11.22.33.44] invalid
first.last@[IPv6:a1::a4:b1::b4:11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33] invalid
first.last@[IPv6:a1::11.22.33.44.55] invalid
first.last@[IPv6:a1::b211.22.33.44] invalid
first.last@[IPv6:a1::b2::11.22.33.44] invalid
first.last@[IPv6:a1::b3:] invalid
first.last@[IPv6::a2::b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3:] invalid
first.last@[IPv6::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4::b1:b2:b3:b4] invalid

Valid: 72/134
Invalid: 116/132

/\A([a-z0-9!#$%&'*+\/=?^_`{|}~-]+(\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"([\040-\041\043-\133\135-\176]|\134[\040-\176])*")@([0-9a-z]([0-9a-z-]*[0-9a-z])?(\.[0-9a-z]([0-9a-z-]*[0-9a-z])?)+|\[((0|[1-9][0-9]{0,2})(.(0|[1-9][0-9]{0,2})){3}|IPv6:([0-9a-f]{1,4}(:[0-9a-f]{1,4}){7}|([0-9a-f]{1,4}(:[0-9a-f]{1,4}){0,5})?::([0-9a-f]{1,4}(:[0-9a-f]{1,4}){0,5})?|[0-9a-f]{1,4}(:[0-9a-f]{1,4}){3}:(0|[1-9][0-9]{0,2})(.(0|[1-9][0-9]{0,2})){3}|([0-9a-f]{1,4}(:[0-9a-f]{1,4}){0,3})?::([0-9a-f]{1,4}(:[0-9a-f]{1,4}){0,3})?:(0|[1-9][0-9]{0,2})(.(0|[1-9][0-9]{0,2})){3}))\])\Z/i

Peter Bowen
Uses preg_match()
These should be valid
[email protected] valid
1234567890123456789012345678901234567890123456789012345678901234@iana.org valid
"first\"last"@iana.org valid
"first@last"@iana.org valid
"first\last"@iana.org valid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] valid
1234567890123456789012345678901234567890123456789012345678@1234567890123456789012345678901234567890123456 [...] valid
first.last@[12.34.56.78] valid
first.last@[IPv6:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:12.34.56.78] valid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78] invalid
first.last@[IPv6:::1111:2222:3333:4444:5555:6666] valid
first.last@[IPv6:1111:2222:3333::4444:5555:6666] valid
first.last@[IPv6:1111:2222:3333:4444:5555:6666::] valid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888] valid
first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org valid
[email protected] valid
[email protected] valid
"first\last"@iana.org valid
first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78] valid
first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777] valid
[email protected] valid
first.last@com invalid
"Abc\@def"@iana.org valid
"Fred\ Bloggs"@iana.org valid
"Joe.\Blow"@iana.org valid
"Abc@def"@iana.org valid
"Fred Bloggs"@iana.org valid
[email protected] valid
customer/[email protected] valid
[email protected] valid
!def!xyz%[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug \"Ace\" L."@iana.org valid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
t*[email protected] valid
[email protected] valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org valid
[email protected] valid
"test.test"@iana.org valid
test."test"@iana.org invalid
"test@test"@iana.org valid
[email protected] valid
[email protected] valid
test@[123.123.123.123] valid
[email protected] valid
[email protected] valid
"test\test"@iana.org valid
test@example invalid
"test\blah"@iana.org valid
"test\blah"@iana.org valid
"test\"blah"@iana.org valid
customer/[email protected] valid
[email protected] valid
[email protected] valid
"Austin@Powers"@iana.org valid
[email protected] valid
"Ima.Fool"@iana.org valid
"Ima Fool"@iana.org valid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first"[email protected] invalid
first."last"@iana.org invalid
"first"."middle"."last"@iana.org invalid
"first.middle"."last"@iana.org invalid
"first.middle.last"@iana.org valid
"first..last"@iana.org valid
"first\\\"last"@iana.org valid
first."mid\dle"."last"@iana.org invalid
"test blah"@iana.org invalid
(foo)cal(bar)@(baz)iamcal.com(quux) invalid
cal@iamcal(woo).(yay)com invalid
cal(woo(yay)hoopla)@iamcal.com invalid
cal(foo\@bar)@iamcal.com invalid
cal(foo\)bar)@iamcal.com invalid
first()[email protected] invalid
pete(his account)@silly.test(his host) invalid
c@(Chris's host.)public.example invalid
jdoe@machine(comment). example invalid
1234 @ local(blah) .machine .example invalid
first(abc.def)[email protected] invalid
first(a"bc.def)[email protected] invalid
first.(")middle.last(")@iana.org invalid
first(abc\(def)@iana.org invalid
first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com invalid
a(a(b(c)d(e(f))g)h(i)j)@iana.org invalid
[email protected] valid
a@b invalid
[email protected] valid
aaa@[123.123.123.123] valid
a@bar invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
"hello my name is"@stutter.com valid
"Test \"Fail\" Ing"@iana.org valid
[email protected] valid
[email protected] valid
[email protected] valid
"Joe\Blow"@iana.org valid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%[email protected] valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|[email protected] valid
first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::] invalid
first.last@[IPv6:::] valid
first.last@[IPv6:::b4] valid
first.last@[IPv6:::b3:b4] valid
first.last@[IPv6:a1::b4] valid
first.last@[IPv6:a1::] valid
first.last@[IPv6:a1:a2::] valid
first.last@[IPv6:0123:4567:89ab:cdef::] valid
first.last@[IPv6:0123:4567:89ab:CDEF::] valid
first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44] valid
first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4::11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33.44] invalid
first.last@[IPv6:a1:a2::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44] invalid
first.last@[IPv6:a1::b2:11.22.33.44] valid
[email protected] valid
[email protected] valid
[email protected] valid
 
These should be invalid
[email protected],com invalid
first\@[email protected] invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org valid
first\@[email protected] invalid
first.last@ invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] valid
first.last@[.12.34.56.78] invalid
first.last@[12.34.56.789] valid
first.last@[::12.34.56.78] invalid
first.last@[IPv5:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999] invalid
first.last@[IPv6:1111:2222::3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:333x::4444:5555] invalid
first.last@[IPv6:1111:2222:33333::4444:5555] invalid
[email protected] invalid
[email protected] invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@[email protected] invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ [email protected] invalid
abc@[email protected] invalid
abc\@[email protected] invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"[email protected] invalid
ote"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\[email protected] invalid
hello [email protected] invalid
[email protected]. invalid
test.iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
test@[email protected] invalid
test@@iana.org invalid
-- test [email protected] invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
[email protected] invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] valid
test@[123.123.123.123 invalid
[email protected]] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
Ima [email protected] invalid
phil.h\@\@[email protected] invalid
foo@[\1.2.3.4] invalid
first.""[email protected] invalid
first\[email protected] invalid
Abc\@[email protected] invalid
Fred\ [email protected] invalid
Joe.\[email protected] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89] invalid
{^c\@**Dog^}@cartoon.com invalid
"foo"(yay)@(hoopla)[1.2.3.4] invalid
cal(foo(bar)@iamcal.com invalid
cal(foo)bar)@iamcal.com invalid
cal(foo\)@iamcal.com invalid
first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012 [...] invalid
first(middle)[email protected] invalid
first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno). [...] invalid
a(a(b(c)d(e(f))g)(h(i)j)@iana.org invalid
.@ invalid
@bar.com invalid
@@bar.com invalid
aaa.com invalid
[email protected] invalid
[email protected] invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] valid
[email protected]. invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Unicode NULL "@char.com invalid
Unicode NULL @char.com invalid
first.last@[IPv6::] invalid
first.last@[IPv6::::] invalid
first.last@[IPv6::b4] invalid
first.last@[IPv6::::b4] invalid
first.last@[IPv6::b3:b4] invalid
first.last@[IPv6::::b3:b4] invalid
first.last@[IPv6:a1:::b4] invalid
first.last@[IPv6:a1:] invalid
first.last@[IPv6:a1:::] invalid
first.last@[IPv6:a1:a2:] invalid
first.last@[IPv6:a1:a2:::] invalid
first.last@[IPv6::11.22.33.44] invalid
first.last@[IPv6::::11.22.33.44] valid
first.last@[IPv6:a1:11.22.33.44] invalid
first.last@[IPv6:a1:::11.22.33.44] valid
first.last@[IPv6:a1:a2:::11.22.33.44] valid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.xx] invalid
first.last@[IPv6:0123:4567:89ab:CDEFF::11.22.33.44] invalid
first.last@[IPv6:a1::a4:b1::b4:11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33] invalid
first.last@[IPv6:a1::11.22.33.44.55] invalid
first.last@[IPv6:a1::b211.22.33.44] invalid
first.last@[IPv6:a1::b2::11.22.33.44] invalid
first.last@[IPv6:a1::b3:] invalid
first.last@[IPv6::a2::b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3:] invalid
first.last@[IPv6::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4::b1:b2:b3:b4] valid

Valid: 92/134
Invalid: 120/132

/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i

James Watts and Francisco Jose Martin Moreno
Uses preg_match()
These should be valid
[email protected] valid
1234567890123456789012345678901234567890123456789012345678901234@iana.org valid
"first\"last"@iana.org invalid
"first@last"@iana.org invalid
"first\last"@iana.org invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
1234567890123456789012345678901234567890123456789012345678@1234567890123456789012345678901234567890123456 [...] valid
first.last@[12.34.56.78] invalid
first.last@[IPv6:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78] invalid
first.last@[IPv6:::1111:2222:3333:4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666::] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888] invalid
first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org valid
[email protected] valid
[email protected] valid
"first\last"@iana.org invalid
first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777] invalid
[email protected] invalid
first.last@com invalid
"Abc\@def"@iana.org invalid
"Fred\ Bloggs"@iana.org invalid
"Joe.\Blow"@iana.org invalid
"Abc@def"@iana.org invalid
"Fred Bloggs"@iana.org invalid
[email protected] valid
customer/[email protected] valid
[email protected] valid
!def!xyz%[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug \"Ace\" L."@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
t*[email protected] valid
[email protected] valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org invalid
[email protected] valid
"test.test"@iana.org invalid
test."test"@iana.org invalid
"test@test"@iana.org invalid
[email protected] invalid
[email protected] valid
test@[123.123.123.123] invalid
[email protected] valid
[email protected] valid
"test\test"@iana.org invalid
test@example invalid
"test\blah"@iana.org invalid
"test\blah"@iana.org invalid
"test\"blah"@iana.org invalid
customer/[email protected] valid
[email protected] valid
[email protected] valid
"Austin@Powers"@iana.org invalid
[email protected] valid
"Ima.Fool"@iana.org invalid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first"[email protected] invalid
first."last"@iana.org invalid
"first"."middle"."last"@iana.org invalid
"first.middle"."last"@iana.org invalid
"first.middle.last"@iana.org invalid
"first..last"@iana.org invalid
"first\\\"last"@iana.org invalid
first."mid\dle"."last"@iana.org invalid
"test blah"@iana.org invalid
(foo)cal(bar)@(baz)iamcal.com(quux) invalid
cal@iamcal(woo).(yay)com invalid
cal(woo(yay)hoopla)@iamcal.com invalid
cal(foo\@bar)@iamcal.com invalid
cal(foo\)bar)@iamcal.com invalid
first()[email protected] invalid
pete(his account)@silly.test(his host) invalid
c@(Chris's host.)public.example invalid
jdoe@machine(comment). example invalid
1234 @ local(blah) .machine .example invalid
first(abc.def)[email protected] invalid
first(a"bc.def)[email protected] invalid
first.(")middle.last(")@iana.org invalid
first(abc\(def)@iana.org invalid
first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com invalid
a(a(b(c)d(e(f))g)h(i)j)@iana.org invalid
[email protected] valid
a@b invalid
[email protected] valid
aaa@[123.123.123.123] invalid
a@bar invalid
[email protected] valid
[email protected] invalid
[email protected] valid
[email protected] valid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
[email protected] valid
[email protected] invalid
[email protected] valid
"Joe\Blow"@iana.org invalid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%[email protected] valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|[email protected] valid
first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::] invalid
first.last@[IPv6:::] invalid
first.last@[IPv6:::b4] invalid
first.last@[IPv6:::b3:b4] invalid
first.last@[IPv6:a1::b4] invalid
first.last@[IPv6:a1::] invalid
first.last@[IPv6:a1:a2::] invalid
first.last@[IPv6:0123:4567:89ab:cdef::] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::] invalid
first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4::11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33.44] invalid
first.last@[IPv6:a1:a2::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44] invalid
first.last@[IPv6:a1::b2:11.22.33.44] invalid
[email protected] valid
[email protected] valid
[email protected] valid
 
These should be invalid
[email protected],com invalid
first\@[email protected] invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org invalid
first\@[email protected] invalid
first.last@ invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
first.last@[.12.34.56.78] invalid
first.last@[12.34.56.789] invalid
first.last@[::12.34.56.78] invalid
first.last@[IPv5:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999] invalid
first.last@[IPv6:1111:2222::3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:333x::4444:5555] invalid
first.last@[IPv6:1111:2222:33333::4444:5555] invalid
[email protected] invalid
[email protected] invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@[email protected] invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ [email protected] invalid
abc@[email protected] invalid
abc\@[email protected] invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"[email protected] invalid
ote"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\[email protected] invalid
hello [email protected] invalid
[email protected]. invalid
test.iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
test@[email protected] invalid
test@@iana.org invalid
-- test [email protected] invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
[email protected] invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] invalid
test@[123.123.123.123 invalid
[email protected]] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
Ima [email protected] invalid
phil.h\@\@[email protected] invalid
foo@[\1.2.3.4] invalid
first.""[email protected] invalid
first\[email protected] invalid
Abc\@[email protected] invalid
Fred\ [email protected] invalid
Joe.\[email protected] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89] invalid
{^c\@**Dog^}@cartoon.com invalid
"foo"(yay)@(hoopla)[1.2.3.4] invalid
cal(foo(bar)@iamcal.com invalid
cal(foo)bar)@iamcal.com invalid
cal(foo\)@iamcal.com invalid
first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012 [...] invalid
first(middle)[email protected] invalid
first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno). [...] invalid
a(a(b(c)d(e(f))g)(h(i)j)@iana.org invalid
.@ invalid
@bar.com invalid
@@bar.com invalid
aaa.com invalid
[email protected] invalid
[email protected] invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
[email protected]. invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Unicode NULL "@char.com invalid
Unicode NULL @char.com invalid
first.last@[IPv6::] invalid
first.last@[IPv6::::] invalid
first.last@[IPv6::b4] invalid
first.last@[IPv6::::b4] invalid
first.last@[IPv6::b3:b4] invalid
first.last@[IPv6::::b3:b4] invalid
first.last@[IPv6:a1:::b4] invalid
first.last@[IPv6:a1:] invalid
first.last@[IPv6:a1:::] invalid
first.last@[IPv6:a1:a2:] invalid
first.last@[IPv6:a1:a2:::] invalid
first.last@[IPv6::11.22.33.44] invalid
first.last@[IPv6::::11.22.33.44] invalid
first.last@[IPv6:a1:11.22.33.44] invalid
first.last@[IPv6:a1:::11.22.33.44] invalid
first.last@[IPv6:a1:a2:::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.xx] invalid
first.last@[IPv6:0123:4567:89ab:CDEFF::11.22.33.44] invalid
first.last@[IPv6:a1::a4:b1::b4:11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33] invalid
first.last@[IPv6:a1::11.22.33.44.55] invalid
first.last@[IPv6:a1::b211.22.33.44] invalid
first.last@[IPv6:a1::b2::11.22.33.44] invalid
first.last@[IPv6:a1::b3:] invalid
first.last@[IPv6::a2::b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3:] invalid
first.last@[IPv6::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4::b1:b2:b3:b4] invalid

Valid: 41/134
Invalid: 129/132

/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(? http://pastie.textmate.org/159503
Uses preg_match()
These should be valid
[email protected] valid
1234567890123456789012345678901234567890123456789012345678901234@iana.org valid
"first\"last"@iana.org invalid
"first@last"@iana.org invalid
"first\last"@iana.org invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
1234567890123456789012345678901234567890123456789012345678@1234567890123456789012345678901234567890123456 [...] valid
first.last@[12.34.56.78] invalid
first.last@[IPv6:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78] invalid
first.last@[IPv6:::1111:2222:3333:4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666::] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888] invalid
first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org valid
[email protected] valid
[email protected] valid
"first\last"@iana.org invalid
first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777] invalid
[email protected] invalid
first.last@com invalid
"Abc\@def"@iana.org invalid
"Fred\ Bloggs"@iana.org invalid
"Joe.\Blow"@iana.org invalid
"Abc@def"@iana.org invalid
"Fred Bloggs"@iana.org invalid
[email protected] valid
customer/[email protected] invalid
[email protected] valid
!def!xyz%[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug \"Ace\" L."@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
t*[email protected] valid
[email protected] valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org invalid
[email protected] valid
"test.test"@iana.org invalid
test."test"@iana.org invalid
"test@test"@iana.org invalid
[email protected] invalid
[email protected] valid
test@[123.123.123.123] invalid
[email protected] valid
[email protected] valid
"test\test"@iana.org invalid
test@example invalid
"test\blah"@iana.org invalid
"test\blah"@iana.org invalid
"test\"blah"@iana.org invalid
customer/[email protected] invalid
[email protected] valid
[email protected] valid
"Austin@Powers"@iana.org invalid
[email protected] valid
"Ima.Fool"@iana.org invalid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first"[email protected] invalid
first."last"@iana.org invalid
"first"."middle"."last"@iana.org invalid
"first.middle"."last"@iana.org invalid
"first.middle.last"@iana.org invalid
"first..last"@iana.org invalid
"first\\\"last"@iana.org invalid
first."mid\dle"."last"@iana.org invalid
"test blah"@iana.org invalid
(foo)cal(bar)@(baz)iamcal.com(quux) invalid
cal@iamcal(woo).(yay)com invalid
cal(woo(yay)hoopla)@iamcal.com invalid
cal(foo\@bar)@iamcal.com invalid
cal(foo\)bar)@iamcal.com invalid
first()[email protected] invalid
pete(his account)@silly.test(his host) invalid
c@(Chris's host.)public.example invalid
jdoe@machine(comment). example invalid
1234 @ local(blah) .machine .example invalid
first(abc.def)[email protected] invalid
first(a"bc.def)[email protected] invalid
first.(")middle.last(")@iana.org invalid
first(abc\(def)@iana.org invalid
first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com invalid
a(a(b(c)d(e(f))g)h(i)j)@iana.org invalid
[email protected] valid
a@b invalid
[email protected] valid
aaa@[123.123.123.123] invalid
a@bar invalid
[email protected] valid
[email protected] invalid
[email protected] valid
[email protected] valid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
[email protected] valid
[email protected] invalid
[email protected] valid
"Joe\Blow"@iana.org invalid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%[email protected] valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|[email protected] invalid
first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::] invalid
first.last@[IPv6:::] invalid
first.last@[IPv6:::b4] invalid
first.last@[IPv6:::b3:b4] invalid
first.last@[IPv6:a1::b4] invalid
first.last@[IPv6:a1::] invalid
first.last@[IPv6:a1:a2::] invalid
first.last@[IPv6:0123:4567:89ab:cdef::] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::] invalid
first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4::11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33.44] invalid
first.last@[IPv6:a1:a2::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44] invalid
first.last@[IPv6:a1::b2:11.22.33.44] invalid
[email protected] valid
[email protected] valid
[email protected] valid
 
These should be invalid
[email protected],com invalid
first\@[email protected] invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org invalid
first\@[email protected] invalid
first.last@ invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
first.last@[.12.34.56.78] invalid
first.last@[12.34.56.789] invalid
first.last@[::12.34.56.78] invalid
first.last@[IPv5:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999] invalid
first.last@[IPv6:1111:2222::3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:333x::4444:5555] invalid
first.last@[IPv6:1111:2222:33333::4444:5555] invalid
[email protected] invalid
[email protected] invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@[email protected] invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ [email protected] invalid
abc@[email protected] invalid
abc\@[email protected] invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"[email protected] invalid
ote"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\[email protected] invalid
hello [email protected] invalid
[email protected]. invalid
test.iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
test@[email protected] invalid
test@@iana.org invalid
-- test [email protected] invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
[email protected] invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] valid
test@[123.123.123.123 invalid
[email protected]] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
Ima [email protected] invalid
phil.h\@\@[email protected] invalid
foo@[\1.2.3.4] invalid
first.""[email protected] invalid
first\[email protected] invalid
Abc\@[email protected] invalid
Fred\ [email protected] invalid
Joe.\[email protected] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89] invalid
{^c\@**Dog^}@cartoon.com invalid
"foo"(yay)@(hoopla)[1.2.3.4] invalid
cal(foo(bar)@iamcal.com invalid
cal(foo)bar)@iamcal.com invalid
cal(foo\)@iamcal.com invalid
first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012 [...] invalid
first(middle)[email protected] invalid
first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno). [...] invalid
a(a(b(c)d(e(f))g)(h(i)j)@iana.org invalid
.@ invalid
@bar.com invalid
@@bar.com invalid
aaa.com invalid
[email protected] invalid
[email protected] invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
[email protected]. invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Unicode NULL "@char.com invalid
Unicode NULL @char.com invalid
first.last@[IPv6::] invalid
first.last@[IPv6::::] invalid
first.last@[IPv6::b4] invalid
first.last@[IPv6::::b4] invalid
first.last@[IPv6::b3:b4] invalid
first.last@[IPv6::::b3:b4] invalid
first.last@[IPv6:a1:::b4] invalid
first.last@[IPv6:a1:] invalid
first.last@[IPv6:a1:::] invalid
first.last@[IPv6:a1:a2:] invalid
first.last@[IPv6:a1:a2:::] invalid
first.last@[IPv6::11.22.33.44] invalid
first.last@[IPv6::::11.22.33.44] invalid
first.last@[IPv6:a1:11.22.33.44] invalid
first.last@[IPv6:a1:::11.22.33.44] invalid
first.last@[IPv6:a1:a2:::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.xx] invalid
first.last@[IPv6:0123:4567:89ab:CDEFF::11.22.33.44] invalid
first.last@[IPv6:a1::a4:b1::b4:11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33] invalid
first.last@[IPv6:a1::11.22.33.44.55] invalid
first.last@[IPv6:a1::b211.22.33.44] invalid
first.last@[IPv6:a1::b2::11.22.33.44] invalid
first.last@[IPv6:a1::b3:] invalid
first.last@[IPv6::a2::b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3:] invalid
first.last@[IPv6::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4::b1:b2:b3:b4] invalid

Valid: 38/134
Invalid: 128/132

/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.([a-z][a-z]+)|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i

http://www.mi-ange.net/blog/msg.php?id=79&lng=en
Uses preg_match()
These should be valid
[email protected] valid
1234567890123456789012345678901234567890123456789012345678901234@iana.org valid
"first\"last"@iana.org invalid
"first@last"@iana.org invalid
"first\last"@iana.org invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
1234567890123456789012345678901234567890123456789012345678@1234567890123456789012345678901234567890123456 [...] valid
first.last@[12.34.56.78] invalid
first.last@[IPv6:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78] invalid
first.last@[IPv6:::1111:2222:3333:4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666::] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888] invalid
first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org valid
[email protected] valid
[email protected] valid
"first\last"@iana.org invalid
first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777] invalid
[email protected] invalid
first.last@com invalid
"Abc\@def"@iana.org invalid
"Fred\ Bloggs"@iana.org invalid
"Joe.\Blow"@iana.org invalid
"Abc@def"@iana.org invalid
"Fred Bloggs"@iana.org invalid
[email protected] valid
customer/[email protected] invalid
[email protected] valid
!def!xyz%[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug \"Ace\" L."@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
t*[email protected] valid
[email protected] valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org invalid
[email protected] valid
"test.test"@iana.org invalid
test."test"@iana.org invalid
"test@test"@iana.org invalid
[email protected] invalid
[email protected] valid
test@[123.123.123.123] invalid
[email protected] valid
[email protected] valid
"test\test"@iana.org invalid
test@example invalid
"test\blah"@iana.org invalid
"test\blah"@iana.org invalid
"test\"blah"@iana.org invalid
customer/[email protected] invalid
[email protected] valid
[email protected] valid
"Austin@Powers"@iana.org invalid
[email protected] valid
"Ima.Fool"@iana.org invalid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first"[email protected] invalid
first."last"@iana.org invalid
"first"."middle"."last"@iana.org invalid
"first.middle"."last"@iana.org invalid
"first.middle.last"@iana.org invalid
"first..last"@iana.org invalid
"first\\\"last"@iana.org invalid
first."mid\dle"."last"@iana.org invalid
"test blah"@iana.org invalid
(foo)cal(bar)@(baz)iamcal.com(quux) invalid
cal@iamcal(woo).(yay)com invalid
cal(woo(yay)hoopla)@iamcal.com invalid
cal(foo\@bar)@iamcal.com invalid
cal(foo\)bar)@iamcal.com invalid
first()[email protected] invalid
pete(his account)@silly.test(his host) invalid
c@(Chris's host.)public.example invalid
jdoe@machine(comment). example invalid
1234 @ local(blah) .machine .example invalid
first(abc.def)[email protected] invalid
first(a"bc.def)[email protected] invalid
first.(")middle.last(")@iana.org invalid
first(abc\(def)@iana.org invalid
first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com invalid
a(a(b(c)d(e(f))g)h(i)j)@iana.org invalid
[email protected] valid
a@b invalid
[email protected] valid
aaa@[123.123.123.123] invalid
a@bar invalid
[email protected] valid
[email protected] invalid
[email protected] valid
[email protected] valid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
"Joe\Blow"@iana.org invalid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%[email protected] valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|[email protected] invalid
first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::] invalid
first.last@[IPv6:::] invalid
first.last@[IPv6:::b4] invalid
first.last@[IPv6:::b3:b4] invalid
first.last@[IPv6:a1::b4] invalid
first.last@[IPv6:a1::] invalid
first.last@[IPv6:a1:a2::] invalid
first.last@[IPv6:0123:4567:89ab:cdef::] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::] invalid
first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4::11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33.44] invalid
first.last@[IPv6:a1:a2::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44] invalid
first.last@[IPv6:a1::b2:11.22.33.44] invalid
[email protected] valid
[email protected] valid
[email protected] valid
 
These should be invalid
[email protected],com invalid
first\@[email protected] invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org invalid
first\@[email protected] invalid
first.last@ invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
first.last@[.12.34.56.78] invalid
first.last@[12.34.56.789] invalid
first.last@[::12.34.56.78] invalid
first.last@[IPv5:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999] invalid
first.last@[IPv6:1111:2222::3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:333x::4444:5555] invalid
first.last@[IPv6:1111:2222:33333::4444:5555] invalid
[email protected] invalid
[email protected] valid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@[email protected] invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ [email protected] invalid
abc@[email protected] invalid
abc\@[email protected] invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"[email protected] invalid
ote"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\[email protected] invalid
hello [email protected] invalid
[email protected]. invalid
test.iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
test@[email protected] invalid
test@@iana.org invalid
-- test [email protected] invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
[email protected] invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] valid
test@[123.123.123.123 invalid
[email protected]] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
Ima [email protected] invalid
phil.h\@\@[email protected] invalid
foo@[\1.2.3.4] invalid
first.""[email protected] invalid
first\[email protected] invalid
Abc\@[email protected] invalid
Fred\ [email protected] invalid
Joe.\[email protected] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89] invalid
{^c\@**Dog^}@cartoon.com invalid
"foo"(yay)@(hoopla)[1.2.3.4] invalid
cal(foo(bar)@iamcal.com invalid
cal(foo)bar)@iamcal.com invalid
cal(foo\)@iamcal.com invalid
first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012 [...] invalid
first(middle)[email protected] invalid
first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno). [...] invalid
a(a(b(c)d(e(f))g)(h(i)j)@iana.org invalid
.@ invalid
@bar.com invalid
@@bar.com invalid
aaa.com invalid
[email protected] invalid
[email protected] invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
[email protected]. invalid
[email protected] invalid
[email protected] valid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Unicode NULL "@char.com invalid
Unicode NULL @char.com invalid
first.last@[IPv6::] invalid
first.last@[IPv6::::] invalid
first.last@[IPv6::b4] invalid
first.last@[IPv6::::b4] invalid
first.last@[IPv6::b3:b4] invalid
first.last@[IPv6::::b3:b4] invalid
first.last@[IPv6:a1:::b4] invalid
first.last@[IPv6:a1:] invalid
first.last@[IPv6:a1:::] invalid
first.last@[IPv6:a1:a2:] invalid
first.last@[IPv6:a1:a2:::] invalid
first.last@[IPv6::11.22.33.44] invalid
first.last@[IPv6::::11.22.33.44] invalid
first.last@[IPv6:a1:11.22.33.44] invalid
first.last@[IPv6:a1:::11.22.33.44] invalid
first.last@[IPv6:a1:a2:::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.xx] invalid
first.last@[IPv6:0123:4567:89ab:CDEFF::11.22.33.44] invalid
first.last@[IPv6:a1::a4:b1::b4:11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33] invalid
first.last@[IPv6:a1::11.22.33.44.55] invalid
first.last@[IPv6:a1::b211.22.33.44] invalid
first.last@[IPv6:a1::b2::11.22.33.44] invalid
first.last@[IPv6:a1::b3:] invalid
first.last@[IPv6::a2::b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3:] invalid
first.last@[IPv6::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4::b1:b2:b3:b4] invalid

Valid: 39/134
Invalid: 126/132

^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$

http://www.quirksmode.org/js/mailcheck.html
Uses eregi()
These should be valid
[email protected] valid
1234567890123456789012345678901234567890123456789012345678901234@iana.org valid
"first\"last"@iana.org invalid
"first@last"@iana.org invalid
"first\last"@iana.org invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] valid
1234567890123456789012345678901234567890123456789012345678@1234567890123456789012345678901234567890123456 [...] valid
first.last@[12.34.56.78] invalid
first.last@[IPv6:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78] invalid
first.last@[IPv6:::1111:2222:3333:4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666::] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888] invalid
first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org valid
[email protected] valid
[email protected] valid
"first\last"@iana.org invalid
first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777] invalid
[email protected] valid
first.last@com invalid
"Abc\@def"@iana.org invalid
"Fred\ Bloggs"@iana.org invalid
"Joe.\Blow"@iana.org invalid
"Abc@def"@iana.org invalid
"Fred Bloggs"@iana.org invalid
[email protected] invalid
customer/[email protected] invalid
[email protected] invalid
!def!xyz%[email protected] invalid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug \"Ace\" L."@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] invalid
[email protected] valid
t*[email protected] invalid
[email protected] invalid
{_test_}@iana.org invalid
"[[ test ]]"@iana.org invalid
[email protected] valid
"test.test"@iana.org invalid
test."test"@iana.org invalid
"test@test"@iana.org invalid
[email protected] valid
[email protected] valid
test@[123.123.123.123] invalid
[email protected] valid
[email protected] valid
"test\test"@iana.org invalid
test@example invalid
"test\blah"@iana.org invalid
"test\blah"@iana.org invalid
"test\"blah"@iana.org invalid
customer/[email protected] invalid
[email protected] valid
[email protected] invalid
"Austin@Powers"@iana.org invalid
[email protected] valid
"Ima.Fool"@iana.org invalid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first"[email protected] invalid
first."last"@iana.org invalid
"first"."middle"."last"@iana.org invalid
"first.middle"."last"@iana.org invalid
"first.middle.last"@iana.org invalid
"first..last"@iana.org invalid
"first\\\"last"@iana.org invalid
first."mid\dle"."last"@iana.org invalid
"test blah"@iana.org invalid
(foo)cal(bar)@(baz)iamcal.com(quux) invalid
cal@iamcal(woo).(yay)com invalid
cal(woo(yay)hoopla)@iamcal.com invalid
cal(foo\@bar)@iamcal.com invalid
cal(foo\)bar)@iamcal.com invalid
first()[email protected] invalid
pete(his account)@silly.test(his host) invalid
c@(Chris's host.)public.example invalid
jdoe@machine(comment). example invalid
1234 @ local(blah) .machine .example invalid
first(abc.def)[email protected] invalid
first(a"bc.def)[email protected] invalid
first.(")middle.last(")@iana.org invalid
first(abc\(def)@iana.org invalid
first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com invalid
a(a(b(c)d(e(f))g)h(i)j)@iana.org invalid
[email protected] valid
a@b invalid
[email protected] valid
aaa@[123.123.123.123] invalid
a@bar invalid
[email protected] valid
[email protected] invalid
[email protected] invalid
[email protected] valid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] invalid
"Joe\Blow"@iana.org invalid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%[email protected] invalid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|[email protected] invalid
first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::] invalid
first.last@[IPv6:::] invalid
first.last@[IPv6:::b4] invalid
first.last@[IPv6:::b3:b4] invalid
first.last@[IPv6:a1::b4] invalid
first.last@[IPv6:a1::] invalid
first.last@[IPv6:a1:a2::] invalid
first.last@[IPv6:0123:4567:89ab:cdef::] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::] invalid
first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4::11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33.44] invalid
first.last@[IPv6:a1:a2::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44] invalid
first.last@[IPv6:a1::b2:11.22.33.44] invalid
[email protected] valid
[email protected] valid
[email protected] valid
 
These should be invalid
[email protected],com invalid
first\@[email protected] invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
[email protected] valid
[email protected] valid
[email protected] valid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org invalid
first\@[email protected] invalid
first.last@ invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] valid
first.last@[.12.34.56.78] invalid
first.last@[12.34.56.789] invalid
first.last@[::12.34.56.78] invalid
first.last@[IPv5:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999] invalid
first.last@[IPv6:1111:2222::3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:333x::4444:5555] invalid
first.last@[IPv6:1111:2222:33333::4444:5555] invalid
[email protected] valid
[email protected] valid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@[email protected] invalid
abc\@iana.org valid
Doug\ \"Ace\"\ [email protected] invalid
abc@[email protected] invalid
abc\@[email protected] invalid
abc\@iana.org valid
@iana.org invalid
doug@ invalid
"[email protected] invalid
ote"@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\[email protected] invalid
hello [email protected] invalid
[email protected]. invalid
test.iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
test@[email protected] invalid
test@@iana.org invalid
-- test [email protected] invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
[email protected] invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] valid
test@[123.123.123.123 invalid
[email protected]] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
Ima [email protected] invalid
phil.h\@\@[email protected] invalid
foo@[\1.2.3.4] invalid
first.""[email protected] invalid
first\[email protected] valid
Abc\@[email protected] invalid
Fred\ [email protected] invalid
Joe.\[email protected] valid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89] invalid
{^c\@**Dog^}@cartoon.com invalid
"foo"(yay)@(hoopla)[1.2.3.4] invalid
cal(foo(bar)@iamcal.com invalid
cal(foo)bar)@iamcal.com invalid
cal(foo\)@iamcal.com invalid
first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012 [...] invalid
first(middle)[email protected] invalid
first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno). [...] invalid
a(a(b(c)d(e(f))g)(h(i)j)@iana.org invalid
.@ invalid
@bar.com invalid
@@bar.com invalid
aaa.com invalid
[email protected] invalid
[email protected] invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
[email protected]. invalid
[email protected] valid
[email protected] valid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Unicode NULL "@char.com invalid
Unicode NULL @char.com invalid
first.last@[IPv6::] invalid
first.last@[IPv6::::] invalid
first.last@[IPv6::b4] invalid
first.last@[IPv6::::b4] invalid
first.last@[IPv6::b3:b4] invalid
first.last@[IPv6::::b3:b4] invalid
first.last@[IPv6:a1:::b4] invalid
first.last@[IPv6:a1:] invalid
first.last@[IPv6:a1:::] invalid
first.last@[IPv6:a1:a2:] invalid
first.last@[IPv6:a1:a2:::] invalid
first.last@[IPv6::11.22.33.44] invalid
first.last@[IPv6::::11.22.33.44] invalid
first.last@[IPv6:a1:11.22.33.44] invalid
first.last@[IPv6:a1:::11.22.33.44] invalid
first.last@[IPv6:a1:a2:::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.xx] invalid
first.last@[IPv6:0123:4567:89ab:CDEFF::11.22.33.44] invalid
first.last@[IPv6:a1::a4:b1::b4:11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33] invalid
first.last@[IPv6:a1::11.22.33.44.55] invalid
first.last@[IPv6:a1::b211.22.33.44] invalid
first.last@[IPv6:a1::b2::11.22.33.44] invalid
first.last@[IPv6:a1::b3:] invalid
first.last@[IPv6::a2::b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3:] invalid
first.last@[IPv6::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4::b1:b2:b3:b4] invalid

Valid: 31/134
Invalid: 106/132

^[a-z0-9\._-]+@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+)$

http://www.zend.com/zend/spotlight/code-gallery-wade5.php?article=code-gallery-wade5&kind=sl&id=1988&open=1&anc=0&view=1#Heading10
Uses eregi()
These should be valid
[email protected] valid
1234567890123456789012345678901234567890123456789012345678901234@iana.org valid
"first\"last"@iana.org invalid
"first@last"@iana.org invalid
"first\last"@iana.org invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
1234567890123456789012345678901234567890123456789012345678@1234567890123456789012345678901234567890123456 [...] valid
first.last@[12.34.56.78] invalid
first.last@[IPv6:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78] invalid
first.last@[IPv6:::1111:2222:3333:4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666::] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888] invalid
first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org valid
[email protected] valid
[email protected] valid
"first\last"@iana.org invalid
first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777] invalid
[email protected] invalid
first.last@com invalid
"Abc\@def"@iana.org invalid
"Fred\ Bloggs"@iana.org invalid
"Joe.\Blow"@iana.org invalid
"Abc@def"@iana.org invalid
"Fred Bloggs"@iana.org invalid
[email protected] invalid
customer/[email protected] invalid
[email protected] invalid
!def!xyz%[email protected] invalid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug \"Ace\" L."@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] invalid
[email protected] valid
t*[email protected] invalid
[email protected] invalid
{_test_}@iana.org invalid
"[[ test ]]"@iana.org invalid
[email protected] valid
"test.test"@iana.org invalid
test."test"@iana.org invalid
"test@test"@iana.org invalid
[email protected] invalid
[email protected] invalid
test@[123.123.123.123] invalid
[email protected] valid
[email protected] valid
"test\test"@iana.org invalid
test@example invalid
"test\blah"@iana.org invalid
"test\blah"@iana.org invalid
"test\"blah"@iana.org invalid
customer/[email protected] invalid
[email protected] valid
[email protected] invalid
"Austin@Powers"@iana.org invalid
[email protected] valid
"Ima.Fool"@iana.org invalid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first"[email protected] invalid
first."last"@iana.org invalid
"first"."middle"."last"@iana.org invalid
"first.middle"."last"@iana.org invalid
"first.middle.last"@iana.org invalid
"first..last"@iana.org invalid
"first\\\"last"@iana.org invalid
first."mid\dle"."last"@iana.org invalid
"test blah"@iana.org invalid
(foo)cal(bar)@(baz)iamcal.com(quux) invalid
cal@iamcal(woo).(yay)com invalid
cal(woo(yay)hoopla)@iamcal.com invalid
cal(foo\@bar)@iamcal.com invalid
cal(foo\)bar)@iamcal.com invalid
first()[email protected] invalid
pete(his account)@silly.test(his host) invalid
c@(Chris's host.)public.example invalid
jdoe@machine(comment). example invalid
1234 @ local(blah) .machine .example invalid
first(abc.def)[email protected] invalid
first(a"bc.def)[email protected] invalid
first.(")middle.last(")@iana.org invalid
first(abc\(def)@iana.org invalid
first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com invalid
a(a(b(c)d(e(f))g)h(i)j)@iana.org invalid
[email protected] valid
a@b invalid
[email protected] valid
aaa@[123.123.123.123] invalid
a@bar invalid
[email protected] valid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] invalid
"Joe\Blow"@iana.org invalid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%[email protected] invalid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|[email protected] invalid
first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::] invalid
first.last@[IPv6:::] invalid
first.last@[IPv6:::b4] invalid
first.last@[IPv6:::b3:b4] invalid
first.last@[IPv6:a1::b4] invalid
first.last@[IPv6:a1::] invalid
first.last@[IPv6:a1:a2::] invalid
first.last@[IPv6:0123:4567:89ab:cdef::] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::] invalid
first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4::11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33.44] invalid
first.last@[IPv6:a1:a2::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44] invalid
first.last@[IPv6:a1::b2:11.22.33.44] invalid
[email protected] valid
[email protected] valid
[email protected] valid
 
These should be invalid
[email protected],com invalid
first\@[email protected] invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
[email protected] valid
[email protected] valid
[email protected] valid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org invalid
first\@[email protected] invalid
first.last@ invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
first.last@[.12.34.56.78] invalid
first.last@[12.34.56.789] invalid
first.last@[::12.34.56.78] invalid
first.last@[IPv5:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999] invalid
first.last@[IPv6:1111:2222::3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:333x::4444:5555] invalid
first.last@[IPv6:1111:2222:33333::4444:5555] invalid
[email protected] invalid
[email protected] invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@[email protected] invalid
abc\@iana.org valid
Doug\ \"Ace\"\ [email protected] invalid
abc@[email protected] invalid
abc\@[email protected] invalid
abc\@iana.org valid
@iana.org invalid
doug@ invalid
"[email protected] invalid
ote"@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\[email protected] invalid
hello [email protected] invalid
[email protected]. invalid
test.iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
test@[email protected] invalid
test@@iana.org invalid
-- test [email protected] invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
[email protected] invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] valid
test@[123.123.123.123 invalid
[email protected]] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
Ima [email protected] invalid
phil.h\@\@[email protected] invalid
foo@[\1.2.3.4] invalid
first.""[email protected] invalid
first\[email protected] valid
Abc\@[email protected] invalid
Fred\ [email protected] invalid
Joe.\[email protected] valid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89] invalid
{^c\@**Dog^}@cartoon.com invalid
"foo"(yay)@(hoopla)[1.2.3.4] invalid
cal(foo(bar)@iamcal.com invalid
cal(foo)bar)@iamcal.com invalid
cal(foo\)@iamcal.com invalid
first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012 [...] invalid
first(middle)[email protected] invalid
first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno). [...] invalid
a(a(b(c)d(e(f))g)(h(i)j)@iana.org invalid
.@ invalid
@bar.com invalid
@@bar.com invalid
aaa.com invalid
[email protected] invalid
[email protected] invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
[email protected]. invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Unicode NULL "@char.com invalid
Unicode NULL @char.com invalid
first.last@[IPv6::] invalid
first.last@[IPv6::::] invalid
first.last@[IPv6::b4] invalid
first.last@[IPv6::::b4] invalid
first.last@[IPv6::b3:b4] invalid
first.last@[IPv6::::b3:b4] invalid
first.last@[IPv6:a1:::b4] invalid
first.last@[IPv6:a1:] invalid
first.last@[IPv6:a1:::] invalid
first.last@[IPv6:a1:a2:] invalid
first.last@[IPv6:a1:a2:::] invalid
first.last@[IPv6::11.22.33.44] invalid
first.last@[IPv6::::11.22.33.44] invalid
first.last@[IPv6:a1:11.22.33.44] invalid
first.last@[IPv6:a1:::11.22.33.44] invalid
first.last@[IPv6:a1:a2:::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.xx] invalid
first.last@[IPv6:0123:4567:89ab:CDEFF::11.22.33.44] invalid
first.last@[IPv6:a1::a4:b1::b4:11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33] invalid
first.last@[IPv6:a1::11.22.33.44.55] invalid
first.last@[IPv6:a1::b211.22.33.44] invalid
first.last@[IPv6:a1::b2::11.22.33.44] invalid
first.last@[IPv6:a1::b3:] invalid
first.last@[IPv6::a2::b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3:] invalid
first.last@[IPv6::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4::b1:b2:b3:b4] invalid

Valid: 26/134
Invalid: 111/132

^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$

http://www.regular-expressions.info/email.html
Uses eregi()
These should be valid
[email protected] valid
1234567890123456789012345678901234567890123456789012345678901234@iana.org valid
"first\"last"@iana.org invalid
"first@last"@iana.org invalid
"first\last"@iana.org invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
1234567890123456789012345678901234567890123456789012345678@1234567890123456789012345678901234567890123456 [...] valid
first.last@[12.34.56.78] invalid
first.last@[IPv6:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78] invalid
first.last@[IPv6:::1111:2222:3333:4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666::] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888] invalid
first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org valid
[email protected] valid
[email protected] valid
"first\last"@iana.org invalid
first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777] invalid
[email protected] invalid
first.last@com invalid
"Abc\@def"@iana.org invalid
"Fred\ Bloggs"@iana.org invalid
"Joe.\Blow"@iana.org invalid
"Abc@def"@iana.org invalid
"Fred Bloggs"@iana.org invalid
[email protected] invalid
customer/[email protected] invalid
[email protected] invalid
!def!xyz%[email protected] invalid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug \"Ace\" L."@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] invalid
[email protected] valid
t*[email protected] invalid
[email protected] invalid
{_test_}@iana.org invalid
"[[ test ]]"@iana.org invalid
[email protected] valid
"test.test"@iana.org invalid
test."test"@iana.org invalid
"test@test"@iana.org invalid
[email protected] invalid
[email protected] invalid
test@[123.123.123.123] invalid
[email protected] valid
[email protected] valid
"test\test"@iana.org invalid
test@example invalid
"test\blah"@iana.org invalid
"test\blah"@iana.org invalid
"test\"blah"@iana.org invalid
customer/[email protected] invalid
[email protected] valid
[email protected] invalid
"Austin@Powers"@iana.org invalid
[email protected] valid
"Ima.Fool"@iana.org invalid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first"[email protected] invalid
first."last"@iana.org invalid
"first"."middle"."last"@iana.org invalid
"first.middle"."last"@iana.org invalid
"first.middle.last"@iana.org invalid
"first..last"@iana.org invalid
"first\\\"last"@iana.org invalid
first."mid\dle"."last"@iana.org invalid
"test blah"@iana.org invalid
(foo)cal(bar)@(baz)iamcal.com(quux) invalid
cal@iamcal(woo).(yay)com invalid
cal(woo(yay)hoopla)@iamcal.com invalid
cal(foo\@bar)@iamcal.com invalid
cal(foo\)bar)@iamcal.com invalid
first()[email protected] invalid
pete(his account)@silly.test(his host) invalid
c@(Chris's host.)public.example invalid
jdoe@machine(comment). example invalid
1234 @ local(blah) .machine .example invalid
first(abc.def)[email protected] invalid
first(a"bc.def)[email protected] invalid
first.(")middle.last(")@iana.org invalid
first(abc\(def)@iana.org invalid
first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com invalid
a(a(b(c)d(e(f))g)h(i)j)@iana.org invalid
[email protected] valid
a@b invalid
[email protected] valid
aaa@[123.123.123.123] invalid
a@bar invalid
[email protected] valid
[email protected] invalid
[email protected] invalid
[email protected] valid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
[email protected] invalid
[email protected] invalid
[email protected] invalid
"Joe\Blow"@iana.org invalid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%[email protected] invalid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|[email protected] invalid
first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::] invalid
first.last@[IPv6:::] invalid
first.last@[IPv6:::b4] invalid
first.last@[IPv6:::b3:b4] invalid
first.last@[IPv6:a1::b4] invalid
first.last@[IPv6:a1::] invalid
first.last@[IPv6:a1:a2::] invalid
first.last@[IPv6:0123:4567:89ab:cdef::] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::] invalid
first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4::11.22.33.44] invalid
first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33.44] invalid
first.last@[IPv6:a1:a2::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44] invalid
first.last@[IPv6:a1::b2:11.22.33.44] invalid
[email protected] valid
[email protected] valid
[email protected] valid
 
These should be invalid
[email protected],com invalid
first\@[email protected] invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
[email protected] valid
[email protected] valid
[email protected] valid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org invalid
first\@[email protected] invalid
first.last@ invalid
x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...] invalid
first.last@[.12.34.56.78] invalid
first.last@[12.34.56.789] invalid
first.last@[::12.34.56.78] invalid
first.last@[IPv5:::12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999] invalid
first.last@[IPv6:1111:2222::3333::4444:5555:6666] invalid
first.last@[IPv6:1111:2222:333x::4444:5555] invalid
first.last@[IPv6:1111:2222:33333::4444:5555] invalid
[email protected] valid
[email protected] valid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@[email protected] invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ [email protected] invalid
abc@[email protected] invalid
abc\@[email protected] invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"[email protected] invalid
ote"@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\[email protected] invalid
hello [email protected] invalid
[email protected]. invalid
test.iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
test@[email protected] invalid
test@@iana.org invalid
-- test [email protected] invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
[email protected] invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] valid
test@[123.123.123.123 invalid
[email protected]] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
Ima [email protected] invalid
phil.h\@\@[email protected] invalid
foo@[\1.2.3.4] invalid
first.""[email protected] invalid
first\[email protected] invalid
Abc\@[email protected] invalid
Fred\ [email protected] invalid
Joe.\[email protected] invalid
first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89] invalid
{^c\@**Dog^}@cartoon.com invalid
"foo"(yay)@(hoopla)[1.2.3.4] invalid
cal(foo(bar)@iamcal.com invalid
cal(foo)bar)@iamcal.com invalid
cal(foo\)@iamcal.com invalid
first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012 [...] invalid
first(middle)[email protected] invalid
first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno). [...] invalid
a(a(b(c)d(e(f))g)(h(i)j)@iana.org invalid
.@ invalid
@bar.com invalid
@@bar.com invalid
aaa.com invalid
[email protected] invalid
[email protected] invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
[email protected]. invalid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] valid
[email protected] invalid
[email protected] valid
"Unicode NULL "@char.com invalid
Unicode NULL @char.com invalid
first.last@[IPv6::] invalid
first.last@[IPv6::::] invalid
first.last@[IPv6::b4] invalid
first.last@[IPv6::::b4] invalid
first.last@[IPv6::b3:b4] invalid
first.last@[IPv6::::b3:b4] invalid
first.last@[IPv6:a1:::b4] invalid
first.last@[IPv6:a1:] invalid
first.last@[IPv6:a1:::] invalid
first.last@[IPv6:a1:a2:] invalid
first.last@[IPv6:a1:a2:::] invalid
first.last@[IPv6::11.22.33.44] invalid
first.last@[IPv6::::11.22.33.44] invalid
first.last@[IPv6:a1:11.22.33.44] invalid
first.last@[IPv6:a1:::11.22.33.44] invalid
first.last@[IPv6:a1:a2:::11.22.33.44] invalid
first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.xx] invalid
first.last@[IPv6:0123:4567:89ab:CDEFF::11.22.33.44] invalid
first.last@[IPv6:a1::a4:b1::b4:11.22.33.44] invalid
first.last@[IPv6:a1::11.22.33] invalid
first.last@[IPv6:a1::11.22.33.44.55] invalid
first.last@[IPv6:a1::b211.22.33.44] invalid
first.last@[IPv6:a1::b2::11.22.33.44] invalid
first.last@[IPv6:a1::b3:] invalid
first.last@[IPv6::a2::b4] invalid
first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3:] invalid
first.last@[IPv6::a2:a3:a4:b1:b2:b3:b4] invalid
first.last@[IPv6:a1:a2:a3:a4::b1:b2:b3:b4] invalid

Valid: 25/134
Invalid: 108/132

你可能感兴趣的:(callback,junit,thinkphp,slf4j,wxpython)