Does anyone have a list of email addresses that I can use to test my JS address validation script? I'm looking for as complete of a list as is reasonable to test the most common edge cases, if not all cases.
-
Think you should make some up. It would be very unproffesional, and probably illegal for anyone here to give you a list of real ones – seanb Nov 18 '08 at 00:42
-
1All the ones with a check mark in the results column here are valid addresses: http://isemail.info/_system/is_email/test/?all – Dominic Sayers Jun 24 '14 at 13:13
3 Answers
Examples valid according to RFC2822
- me@example.com
- a.nonymous@example.com
- name+tag@example.com
- name\@tag@example.com – this is a valid email address containing two @ symbols.
- spaces\ are\ allowed@example.com
- "spaces may be quoted"@example.com
- !#$%&'*+-/=.?^_`{|}~@[1.0.0.127]
- !#$%&'*+-/=.?^_`{|}~@[IPv6:0123:4567:89AB:CDEF:0123:4567:89AB:CDEF]
- me(this is a comment)@example.com – comments are discouraged but not prohibited by RFC2822.
Examples invalid according to RFC2822s
- me@
- @example.com
- me.@example.com
- .me@example.com
- me@example..com
- me.example@com
- me\@example.com
From : http://en.wikibooks.org/wiki/JavaScript/Best_Practices
-
5+1 | name+tag@example.com is one that I try to use all the time (read: Gmail filters) but is classed as invalid for just about every site that has "rolled it's own" without regard to RFC2822. It's infuriating! – Pat Hermens Nov 19 '08 at 02:26
-
1me.example@com is valid. The wikipedia article mentioned incorrectly interprets RFC2822 in that case. RFC2822 uses augmented Backus-Naur Form to state that a domain can be (among other things) `atom *("." atom)` and as per the style of Aug.BNF used, * means 0 to infinity occurrences of whatever follows when not specified otherwise. Hence, the following `("."atom)` part is optional. And, as me.example is a valid local part of the email, me.example@com must also be acceptable. – binderbound Jan 29 '14 at 02:29
-
1also the following (which claim to be valid) are not valid: `name\@tag@example` `spaces\ are\ allowed@example.com`. This is another incorrect interpretation of RFC282. Nowhere does it say you can escape @ and spaces to get a valid email. In fact it specifically says they must be quoted. Seriously - you can't blindly trust wikipedia, even nowadays. They don't have the resources to check what people post properly. They just check you have and reference sources, which is not good enough. – binderbound Jan 29 '14 at 02:56
-
This incorrect email should most certainly be added to the list of to test addresses, because it is the most common mistake made: `addressee@domain`. Quite often, the extension (`.com`, `.org`, `.co.uk`, etc.) is forgotten by the user. – Frank Conijn - Support Ukraine Jun 25 '14 at 01:29
-
-
-
A friend of mine has an address like `a.toot.@example.com`, so that trailing dot is definitely valid. – uliwitness Mar 27 '22 at 08:29
I've now collated test cases from Cal Henderson, Dave Child, Phil Haack, Doug Lovell and RFC 3696. 164 test addresses in all.
I ran all these tests against all the validators I could find. The comparison is here: http://www.dominicsayers.com/isemail
I'll try to keep this page up-to-date as people enhance their validators. Thanks to Cal, Dave and Phil for their help and co-operation in compiling these tests and constructive criticism of my own validator.
People should be aware of the errata against RFC 3696 in particular. Three of the canonical examples are in fact invalid addresses. And the maximum length of an address is 254 or 256 characters, not 320.

- 1,783
- 2
- 20
- 26
The domain part (after the last @), is a series of string labels divided by a dot.
Each label is a string of 1 to 63 octets consisting of A-Z, a-z 0-9 or hyphen (-)
The maximum size of the domain is 255 octets.
To be compatible with arpanet, each label must start with a letter and end with a letter or digit but some TLD:s now allows an all numeric domain, like 0.nu
Note that the TLD is allowed to be 63 octets. Very many scrips wrongly restricts it to 2-3 octets making domain.name invalid.
Example?
abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ.!#$%&'+-/=.?^`{|}~@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-0123456789.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.0.1.2.3.4.5.6.7.8.9.a-z.A-Z.0-9.a0.b1.c2.d3.e4.f5.g6.h7.i8.j9.K0.L1.M2.N3.O.domain.name
(and no, it isn't registered)
Update: With IDNA almost everything is possible:
- punnycode@XN--0ZWM56D.XN--HGBK6AJ7F53BBA
- idna_in_clear(?)_text@例子.测试.مثال.آزمایشی
See also:
https://stackoverflow.com/questions/3232/how-far-should-one-take-e-mail-address-validation
http://www.leshazlewood.com/?p=5
Update: Bobince suggested to test for a dot in the domain name.
Summary: Only test for @ and a dot in the domain part and then send a confirmation email.
Here is an example that test for @ and dot:
- There must be at least one @
- There must be at least one char in the local part ( pos > 0)
- There must be at least one dot in the domain part
- The domain part must be at lest 4 characters
Here is a simple one:
function isEmail(address) {
var pos = address.lastIndexOf("@");
return pos > 0 && (address.lastIndexOf(".") > pos) && (address.length - pos > 4);
}
Or a function that returns the local and domain part in an object ( if you want to process it even further, for example convert it to punycode)
function isEmail(address) {
var pos = address.lastIndexOf("@");
return pos > 0 && (address.lastIndexOf(".") > pos) && (address.length - pos > 4) ?
{
local:address.substr(0,pos < 0 ? 0 : pos),
domain:address.substr(pos+1)
}: false;
}
-
Testing for ‘.’ is also useful to catch the people who just put ‘hotmail’ with no TLD. We can, I think, safely assume no-one will be filling in an address @ a TLD itself. – bobince Nov 18 '08 at 10:01
-
I'm not sure if it is legal or not to have an address at the TLD. Technically it should be possible, but I am not aware of any that have it. – some Nov 19 '08 at 01:41
-
Out of interest: @Dominc_Sayers commented on his linked page *"Today I found someone with a working email address at a Top Level Domain. In other words an email address with no dots in the domain part. [...] he has an address at the Ukrainian TLD .ua"* http://isemail.info/_system/is_email/test/?all – ptim Jul 17 '17 at 11:48
-
1@ptim With all the new TLDs there is an even larger chance that someone will have an email address at the TLD. To test if it could be an email address, check for a @ and (optional) convert all domain parts via punnycode to ASCII and check the length of each label. – some Jul 18 '17 at 15:06