How can I get the list of valid email addresses?

286    Asked by AlGerman in Cyber Security , Asked on Feb 15, 2022

 I need to validate an Email address field comprehensively. From Wikipedia, I pulled the following valid/invalid email addresses, is there anything I am missing here? Thanks


Valid email addresses

prettyandsimple@example.com

very.common@example.com

disposable.style.email.with+symbol@example.com

other.email-with-dash@example.com

fully-qualified-domain@example.com

x@example.com (one-letter local-part)

"very.unusual.@.unusual.com"@example.com

"very.(),:;<>[]".VERY."very@ "very".unusual"@strange.example.com

example-indeed@strange-example.com

admin@mailserver1 (local domain name with no TLD)

/#!$%&'*+-/=?^_`{}|~@example.org

"()<>[]:,;@\"!#$%&'-/=?^_`{}| ~.a"@example.org

" "@example.org (space between the quotes)

example@s.solutions (see the List of Internet top-level domains)

user@localserver

user@tt (although ICANN highly discourages dotless email addresses)

user@[IPv6:2001:DB8::1]

Invalid email addresses

Abc.example.com (no @ character)

A@b@c@example.com (only one @ is allowed outside quotation marks)

a"b(c)d,e:f;gi[jk]l@example.com (none of the special characters in this local-part are allowed outside quotation marks)

just"not"right@example.com (quoted strings must be dot separated or the only element making up the local-part)

this is"notallowed@example.com (spaces, quotes, and backslashes may only exist when within quoted strings and preceded by a backslash)

this still"notallowed@example.com (even if escaped (preceded by a backslash), spaces, quotes, and backslashes must still be contained by quotes)

1234567890123456789012345678901234567890123456789012345678901234+x@example.com (too long)

john..doe@example.com (double dot before @)

example@localhost (sent from localhost)

with caveat: Gmail lets this through, Email address#Local-part the dots altogether

john.doe@example..com (double dot after @)

"much.more unusual"@example.com

a valid address with a leading space

a valid address with a trailing space


Answered by Alan Taylor

Yes, for the list of valid email addresses and for the negative cases like this one:


  a"b(c)d,e:f;gi[jk]l@example.com (none of the special characters in this local-part are allowed outside quotation marks)

You will need to split these up into one test per special character. Otherwise your test may pass because it finds a [ but could fail if only a ; were present. I.e. if the regex of your developer only finds some characters, you'll never know if you test them together.

Edit: another consideration. How will you test this validation: in the GUI? If so, reconsider your test level for this test... Testing a Regex extensively should be automated at unit test (or API) level. The actual inputs in the GUI should be limited just to see if the validation is triggered and displayed properly.


Your Answer

Interviews

Parent Categories