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

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
first.last@iana.org 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
first.last@3com.com valid
first.last@123.iana.org 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
first.last@example.123 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
user+mailbox@iana.org valid
customer/department=shipping@iana.org valid
$A12345@iana.org valid
!def!xyz%abc@iana.org valid
_somename@iana.org valid
dclo@us.ibm.com valid
peter.piper@iana.org valid
"Doug \"Ace\" L."@iana.org invalid
test@iana.org valid
TEST@iana.org valid
1234567890@iana.org valid
test+test@iana.org valid
test-test@iana.org valid
t*est@iana.org valid
+1~1+@iana.org valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org invalid
test.test@iana.org valid
"test.test"@iana.org valid
test."test"@iana.org valid
"test@test"@iana.org valid
test@123.123.123.x123 valid
test@123.123.123.123 invalid
test@[123.123.123.123] valid
test@example.iana.org valid
test@example.example.iana.org 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/department@iana.org valid
_Yosemite.Sam@iana.org valid
~@iana.org valid
"Austin@Powers"@iana.org valid
Ima.Fool@iana.org valid
"Ima.Fool"@iana.org valid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org valid
"first".middle."last"@iana.org valid
"first".last@iana.org 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().last@iana.org 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).last@iana.org invalid
first(a"bc.def).last@iana.org 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
name.lastname@domain.com valid
a@b invalid
a@bar.com valid
aaa@[123.123.123.123] valid
a@bar invalid
a-b@bar.com valid
+@b.c valid
+@b.com valid
a@b.co-foo.uk valid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
valid@about.museum valid
shaitan@my-domain.thisisminekthx valid
foobar@192.168.0.1 invalid
"Joe\Blow"@iana.org valid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%uucp!path@berkeley.edu valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|~test@gmail.com 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
test@test.com valid
test@xn--example.com valid
test@example.com valid
 
These should be invalid
first.last@sub.do,com invalid
first\@last@iana.org invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] invalid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org invalid
.first.last@iana.org invalid
first.last.@iana.org invalid
first..last@iana.org invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org valid
first\@last@iana.org 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
first.last@-xample.com invalid
first.last@exampl-.com invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org invalid
abc\@def@iana.org invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ Lovell@iana.org invalid
abc@def@iana.org invalid
abc\@def@iana.org invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"qu@iana.org invalid
ote"@iana.org invalid
.dot@iana.org invalid
dot.@iana.org invalid
two..dot@iana.org invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\.@iana.org invalid
hello world@iana.org invalid
gatsby@f.sc.ot.t.f.i.tzg.era.l.d. invalid
test.iana.org invalid
test.@iana.org invalid
test..test@iana.org invalid
.test@iana.org invalid
test@test@iana.org invalid
test@@iana.org invalid
-- test --@iana.org invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
test@.org invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] invalid
test@[123.123.123.123 invalid
test@123.123.123.123] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
.wooly@iana.org invalid
wo..oly@iana.org invalid
pootietang.@iana.org invalid
.@iana.org invalid
Ima Fool@iana.org invalid
phil.h\@\@ck@haacked.com invalid
foo@[\1.2.3.4] invalid
first."".last@iana.org valid
first\last@iana.org invalid
Abc\@def@iana.org invalid
Fred\ Bloggs@iana.org invalid
Joe.\Blow@iana.org 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)last@iana.org 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
aaa@.com invalid
aaa@.123 invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
a@bar.com. invalid
a@-b.com invalid
a@b-.com invalid
-@..com invalid
-@a..com invalid
invalid@about.museum- invalid
test@...........com 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
first.last@iana.org 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
first.last@3com.com valid
first.last@123.iana.org 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
first.last@example.123 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
user+mailbox@iana.org valid
customer/department=shipping@iana.org valid
$A12345@iana.org valid
!def!xyz%abc@iana.org valid
_somename@iana.org valid
dclo@us.ibm.com valid
peter.piper@iana.org valid
"Doug \"Ace\" L."@iana.org valid
test@iana.org valid
TEST@iana.org valid
1234567890@iana.org valid
test+test@iana.org valid
test-test@iana.org valid
t*est@iana.org valid
+1~1+@iana.org valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org valid
test.test@iana.org valid
"test.test"@iana.org valid
test."test"@iana.org invalid
"test@test"@iana.org valid
test@123.123.123.x123 invalid
test@123.123.123.123 invalid
test@[123.123.123.123] valid
test@example.iana.org valid
test@example.example.iana.org 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/department@iana.org valid
_Yosemite.Sam@iana.org valid
~@iana.org valid
"Austin@Powers"@iana.org valid
Ima.Fool@iana.org valid
"Ima.Fool"@iana.org valid
"Ima Fool"@iana.org valid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first".last@iana.org 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().last@iana.org 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).last@iana.org valid
first(a"bc.def).last@iana.org 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
name.lastname@domain.com valid
a@b invalid
a@bar.com valid
aaa@[123.123.123.123] valid
a@bar invalid
a-b@bar.com valid
+@b.c invalid
+@b.com valid
a@b.co-foo.uk valid
"hello my name is"@stutter.com valid
"Test \"Fail\" Ing"@iana.org valid
valid@about.museum valid
shaitan@my-domain.thisisminekthx invalid
foobar@192.168.0.1 invalid
"Joe\Blow"@iana.org valid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%uucp!path@berkeley.edu valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|~test@gmail.com 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
test@test.com valid
test@xn--example.com valid
test@example.com valid
 
These should be invalid
first.last@sub.do,com invalid
first\@last@iana.org valid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] invalid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org invalid
.first.last@iana.org invalid
first.last.@iana.org invalid
first..last@iana.org invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org valid
""@iana.org invalid
first\@last@iana.org 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
first.last@-xample.com invalid
first.last@exampl-.com invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org invalid
abc\@def@iana.org valid
abc\@iana.org invalid
Doug\ \"Ace\"\ Lovell@iana.org valid
abc@def@iana.org invalid
abc\@def@iana.org valid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"qu@iana.org invalid
ote"@iana.org invalid
.dot@iana.org invalid
dot.@iana.org invalid
two..dot@iana.org invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\.@iana.org invalid
hello world@iana.org invalid
gatsby@f.sc.ot.t.f.i.tzg.era.l.d. invalid
test.iana.org invalid
test.@iana.org invalid
test..test@iana.org invalid
.test@iana.org invalid
test@test@iana.org invalid
test@@iana.org invalid
-- test --@iana.org invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
test@.org invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] invalid
test@[123.123.123.123 invalid
test@123.123.123.123] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
.wooly@iana.org invalid
wo..oly@iana.org invalid
pootietang.@iana.org invalid
.@iana.org invalid
Ima Fool@iana.org invalid
phil.h\@\@ck@haacked.com valid
foo@[\1.2.3.4] invalid
first."".last@iana.org invalid
first\last@iana.org invalid
Abc\@def@iana.org valid
Fred\ Bloggs@iana.org valid
Joe.\Blow@iana.org 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)last@iana.org 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
aaa@.com invalid
aaa@.123 invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
a@bar.com. invalid
a@-b.com invalid
a@b-.com invalid
-@..com invalid
-@a..com valid
invalid@about.museum- invalid
test@...........com 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
first.last@iana.org 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
first.last@3com.com valid
first.last@123.iana.org 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
first.last@example.123 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
user+mailbox@iana.org valid
customer/department=shipping@iana.org valid
$A12345@iana.org valid
!def!xyz%abc@iana.org valid
_somename@iana.org valid
dclo@us.ibm.com valid
peter.piper@iana.org valid
"Doug \"Ace\" L."@iana.org valid
test@iana.org valid
TEST@iana.org valid
1234567890@iana.org valid
test+test@iana.org valid
test-test@iana.org valid
t*est@iana.org valid
+1~1+@iana.org valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org valid
test.test@iana.org valid
"test.test"@iana.org valid
test."test"@iana.org invalid
"test@test"@iana.org valid
test@123.123.123.x123 valid
test@123.123.123.123 valid
test@[123.123.123.123] valid
test@example.iana.org valid
test@example.example.iana.org 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/department@iana.org valid
_Yosemite.Sam@iana.org valid
~@iana.org valid
"Austin@Powers"@iana.org valid
Ima.Fool@iana.org valid
"Ima.Fool"@iana.org valid
"Ima Fool"@iana.org valid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first".last@iana.org 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().last@iana.org 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).last@iana.org invalid
first(a"bc.def).last@iana.org 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
name.lastname@domain.com valid
a@b invalid
a@bar.com valid
aaa@[123.123.123.123] valid
a@bar invalid
a-b@bar.com valid
+@b.c valid
+@b.com valid
a@b.co-foo.uk valid
"hello my name is"@stutter.com valid
"Test \"Fail\" Ing"@iana.org valid
valid@about.museum valid
shaitan@my-domain.thisisminekthx valid
foobar@192.168.0.1 valid
"Joe\Blow"@iana.org valid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%uucp!path@berkeley.edu valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|~test@gmail.com 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
test@test.com valid
test@xn--example.com valid
test@example.com valid
 
These should be invalid
first.last@sub.do,com invalid
first\@last@iana.org invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
.first.last@iana.org invalid
first.last.@iana.org invalid
first..last@iana.org invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org valid
first\@last@iana.org 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
first.last@-xample.com invalid
first.last@exampl-.com invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@def@iana.org invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ Lovell@iana.org invalid
abc@def@iana.org invalid
abc\@def@iana.org invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"qu@iana.org invalid
ote"@iana.org invalid
.dot@iana.org invalid
dot.@iana.org invalid
two..dot@iana.org invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\.@iana.org invalid
hello world@iana.org invalid
gatsby@f.sc.ot.t.f.i.tzg.era.l.d. invalid
test.iana.org invalid
test.@iana.org invalid
test..test@iana.org invalid
.test@iana.org invalid
test@test@iana.org invalid
test@@iana.org invalid
-- test --@iana.org invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
test@.org invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] valid
test@[123.123.123.123 invalid
test@123.123.123.123] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
.wooly@iana.org invalid
wo..oly@iana.org invalid
pootietang.@iana.org invalid
.@iana.org invalid
Ima Fool@iana.org invalid
phil.h\@\@ck@haacked.com invalid
foo@[\1.2.3.4] invalid
first."".last@iana.org invalid
first\last@iana.org invalid
Abc\@def@iana.org invalid
Fred\ Bloggs@iana.org invalid
Joe.\Blow@iana.org 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)last@iana.org 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
aaa@.com invalid
aaa@.123 invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] valid
a@bar.com. invalid
a@-b.com invalid
a@b-.com invalid
-@..com invalid
-@a..com invalid
invalid@about.museum- invalid
test@...........com 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
first.last@iana.org 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
first.last@3com.com valid
first.last@123.iana.org 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
first.last@example.123 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
user+mailbox@iana.org valid
customer/department=shipping@iana.org valid
$A12345@iana.org valid
!def!xyz%abc@iana.org valid
_somename@iana.org valid
dclo@us.ibm.com valid
peter.piper@iana.org valid
"Doug \"Ace\" L."@iana.org invalid
test@iana.org valid
TEST@iana.org valid
1234567890@iana.org valid
test+test@iana.org valid
test-test@iana.org valid
t*est@iana.org valid
+1~1+@iana.org valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org invalid
test.test@iana.org valid
"test.test"@iana.org invalid
test."test"@iana.org invalid
"test@test"@iana.org invalid
test@123.123.123.x123 invalid
test@123.123.123.123 valid
test@[123.123.123.123] invalid
test@example.iana.org valid
test@example.example.iana.org 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/department@iana.org valid
_Yosemite.Sam@iana.org valid
~@iana.org valid
"Austin@Powers"@iana.org invalid
Ima.Fool@iana.org valid
"Ima.Fool"@iana.org invalid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first".last@iana.org 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().last@iana.org 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).last@iana.org invalid
first(a"bc.def).last@iana.org 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
name.lastname@domain.com valid
a@b invalid
a@bar.com valid
aaa@[123.123.123.123] invalid
a@bar invalid
a-b@bar.com valid
+@b.c invalid
+@b.com valid
a@b.co-foo.uk valid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
valid@about.museum valid
shaitan@my-domain.thisisminekthx invalid
foobar@192.168.0.1 valid
"Joe\Blow"@iana.org invalid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%uucp!path@berkeley.edu valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|~test@gmail.com 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
test@test.com valid
test@xn--example.com valid
test@example.com valid
 
These should be invalid
first.last@sub.do,com invalid
first\@last@iana.org invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
.first.last@iana.org invalid
first.last.@iana.org invalid
first..last@iana.org invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org invalid
first\@last@iana.org 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
first.last@-xample.com invalid
first.last@exampl-.com invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@def@iana.org invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ Lovell@iana.org invalid
abc@def@iana.org invalid
abc\@def@iana.org invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"qu@iana.org invalid
ote"@iana.org invalid
.dot@iana.org invalid
dot.@iana.org invalid
two..dot@iana.org invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\.@iana.org invalid
hello world@iana.org invalid
gatsby@f.sc.ot.t.f.i.tzg.era.l.d. invalid
test.iana.org invalid
test.@iana.org invalid
test..test@iana.org invalid
.test@iana.org invalid
test@test@iana.org invalid
test@@iana.org invalid
-- test --@iana.org invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
test@.org invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] invalid
test@[123.123.123.123 invalid
test@123.123.123.123] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
.wooly@iana.org invalid
wo..oly@iana.org invalid
pootietang.@iana.org invalid
.@iana.org invalid
Ima Fool@iana.org invalid
phil.h\@\@ck@haacked.com invalid
foo@[\1.2.3.4] invalid
first."".last@iana.org invalid
first\last@iana.org invalid
Abc\@def@iana.org invalid
Fred\ Bloggs@iana.org invalid
Joe.\Blow@iana.org 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)last@iana.org 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
aaa@.com invalid
aaa@.123 invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
a@bar.com. invalid
a@-b.com invalid
a@b-.com invalid
-@..com invalid
-@a..com invalid
invalid@about.museum- invalid
test@...........com 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.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD

http://pastie.textmate.org/159503
Uses preg_match()
These should be valid
first.last@iana.org 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
first.last@3com.com valid
first.last@123.iana.org 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
first.last@example.123 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
user+mailbox@iana.org valid
customer/department=shipping@iana.org invalid
$A12345@iana.org valid
!def!xyz%abc@iana.org valid
_somename@iana.org valid
dclo@us.ibm.com valid
peter.piper@iana.org valid
"Doug \"Ace\" L."@iana.org invalid
test@iana.org valid
TEST@iana.org valid
1234567890@iana.org valid
test+test@iana.org valid
test-test@iana.org valid
t*est@iana.org valid
+1~1+@iana.org valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org invalid
test.test@iana.org valid
"test.test"@iana.org invalid
test."test"@iana.org invalid
"test@test"@iana.org invalid
test@123.123.123.x123 invalid
test@123.123.123.123 valid
test@[123.123.123.123] invalid
test@example.iana.org valid
test@example.example.iana.org 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/department@iana.org invalid
_Yosemite.Sam@iana.org valid
~@iana.org valid
"Austin@Powers"@iana.org invalid
Ima.Fool@iana.org valid
"Ima.Fool"@iana.org invalid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first".last@iana.org 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().last@iana.org 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).last@iana.org invalid
first(a"bc.def).last@iana.org 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
name.lastname@domain.com valid
a@b invalid
a@bar.com valid
aaa@[123.123.123.123] invalid
a@bar invalid
a-b@bar.com valid
+@b.c invalid
+@b.com valid
a@b.co-foo.uk valid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
valid@about.museum valid
shaitan@my-domain.thisisminekthx invalid
foobar@192.168.0.1 valid
"Joe\Blow"@iana.org invalid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%uucp!path@berkeley.edu valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|~test@gmail.com 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
test@test.com valid
test@xn--example.com valid
test@example.com valid
 
These should be invalid
first.last@sub.do,com invalid
first\@last@iana.org invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
.first.last@iana.org invalid
first.last.@iana.org invalid
first..last@iana.org invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org invalid
first\@last@iana.org 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
first.last@-xample.com invalid
first.last@exampl-.com invalid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@def@iana.org invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ Lovell@iana.org invalid
abc@def@iana.org invalid
abc\@def@iana.org invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"qu@iana.org invalid
ote"@iana.org invalid
.dot@iana.org invalid
dot.@iana.org invalid
two..dot@iana.org invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\.@iana.org invalid
hello world@iana.org invalid
gatsby@f.sc.ot.t.f.i.tzg.era.l.d. invalid
test.iana.org invalid
test.@iana.org invalid
test..test@iana.org invalid
.test@iana.org invalid
test@test@iana.org invalid
test@@iana.org invalid
-- test --@iana.org invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
test@.org invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] valid
test@[123.123.123.123 invalid
test@123.123.123.123] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
.wooly@iana.org invalid
wo..oly@iana.org invalid
pootietang.@iana.org invalid
.@iana.org invalid
Ima Fool@iana.org invalid
phil.h\@\@ck@haacked.com invalid
foo@[\1.2.3.4] invalid
first."".last@iana.org invalid
first\last@iana.org invalid
Abc\@def@iana.org invalid
Fred\ Bloggs@iana.org invalid
Joe.\Blow@iana.org 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)last@iana.org 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
aaa@.com invalid
aaa@.123 invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
a@bar.com. invalid
a@-b.com invalid
a@b-.com invalid
-@..com invalid
-@a..com invalid
invalid@about.museum- invalid
test@...........com 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
first.last@iana.org 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
first.last@3com.com valid
first.last@123.iana.org 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
first.last@example.123 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
user+mailbox@iana.org valid
customer/department=shipping@iana.org invalid
$A12345@iana.org valid
!def!xyz%abc@iana.org valid
_somename@iana.org valid
dclo@us.ibm.com valid
peter.piper@iana.org valid
"Doug \"Ace\" L."@iana.org invalid
test@iana.org valid
TEST@iana.org valid
1234567890@iana.org valid
test+test@iana.org valid
test-test@iana.org valid
t*est@iana.org valid
+1~1+@iana.org valid
{_test_}@iana.org valid
"[[ test ]]"@iana.org invalid
test.test@iana.org valid
"test.test"@iana.org invalid
test."test"@iana.org invalid
"test@test"@iana.org invalid
test@123.123.123.x123 invalid
test@123.123.123.123 valid
test@[123.123.123.123] invalid
test@example.iana.org valid
test@example.example.iana.org 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/department@iana.org invalid
_Yosemite.Sam@iana.org valid
~@iana.org valid
"Austin@Powers"@iana.org invalid
Ima.Fool@iana.org valid
"Ima.Fool"@iana.org invalid
"Ima Fool"@iana.org invalid
"first"."last"@iana.org invalid
"first".middle."last"@iana.org invalid
"first".last@iana.org 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().last@iana.org 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).last@iana.org invalid
first(a"bc.def).last@iana.org 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
name.lastname@domain.com valid
a@b invalid
a@bar.com valid
aaa@[123.123.123.123] invalid
a@bar invalid
a-b@bar.com valid
+@b.c invalid
+@b.com valid
a@b.co-foo.uk valid
"hello my name is"@stutter.com invalid
"Test \"Fail\" Ing"@iana.org invalid
valid@about.museum valid
shaitan@my-domain.thisisminekthx valid
foobar@192.168.0.1 valid
"Joe\Blow"@iana.org invalid
HM2Kinsists@(that comments are allowed)this.is.ok invalid
user%uucp!path@berkeley.edu valid
first.last @iana.org invalid
cdburgess+!#$%&'*-/=?+_{}|~test@gmail.com 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
test@test.com valid
test@xn--example.com valid
test@example.com valid
 
These should be invalid
first.last@sub.do,com invalid
first\@last@iana.org invalid
123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...] valid
first.last invalid
12345678901234567890123456789012345678901234567890123456789012345@iana.org valid
.first.last@iana.org invalid
first.last.@iana.org invalid
first..last@iana.org invalid
"first"last"@iana.org invalid
"""@iana.org invalid
"\"@iana.org invalid
""@iana.org invalid
first\@last@iana.org 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
first.last@-xample.com invalid
first.last@exampl-.com valid
first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org valid
abc\@def@iana.org invalid
abc\@iana.org invalid
Doug\ \"Ace\"\ Lovell@iana.org invalid
abc@def@iana.org invalid
abc\@def@iana.org invalid
abc\@iana.org invalid
@iana.org invalid
doug@ invalid
"qu@iana.org invalid
ote"@iana.org invalid
.dot@iana.org invalid
dot.@iana.org invalid
two..dot@iana.org invalid
"Doug "Ace" L."@iana.org invalid
Doug\ \"Ace\"\ L\.@iana.org invalid
hello world@iana.org invalid
gatsby@f.sc.ot.t.f.i.tzg.era.l.d. invalid
test.iana.org invalid
test.@iana.org invalid
test..test@iana.org invalid
.test@iana.org invalid
test@test@iana.org invalid
test@@iana.org invalid
-- test --@iana.org invalid
[test]@iana.org invalid
"test"test"@iana.org invalid
()[]\;:,><@iana.org invalid
test@. invalid
test@example. invalid
test@.org invalid
test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...] valid
test@[123.123.123.123 invalid
test@123.123.123.123] invalid
NotAnEmail invalid
@NotAnEmail invalid
"test"blah"@iana.org invalid
.wooly@iana.org invalid
wo..oly@iana.org invalid
pootietang.@iana.org invalid
.@iana.org invalid
Ima Fool@iana.org invalid
phil.h\@\@ck@haacked.com invalid
foo@[\1.2.3.4] invalid
first."".last@iana.org invalid
first\last@iana.org invalid
Abc\@def@iana.org invalid
Fred\ Bloggs@iana.org invalid
Joe.\Blow@iana.org 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)last@iana.org 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
aaa@.com invalid
aaa@.123 invalid
aaa@[123.123.123.123]a invalid
aaa@[123.123.123.333] invalid
a@bar.com. invalid
a@-b.com invalid
a@b-.com valid
-@..com invalid
-@a..com invalid
invalid@about.museum- invalid
test@...........com 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
first.last@iana.org