メールアドレスに使用できる文字列は規定されているようです。
メールアドレスのフォーマットを規定する文書として、RFCのRFC 5321 (Simple Mail Transfer Protocol) [1]およびRFC 5322 (Internet Message Format) [2]が存在し、メールアドレスに使用できる文字を定義している[3]。
参照元: メールアドレス – Wikipedia
メールアドレスのバリデーションを見ていきます。
バリデーション例
emailregex.com
Email Address Regular Expression That 99.99% Works.
サイト下のDISQUSのコメント欄で議論が色々とされていますが。
validationEngine
jQueryのバリデーションでよく聞くvalidationEngineですけれど、custom[email]のバリデーションでなぜか末尾のドットが許容されてます。。。
例えば「mail@officetnk.com.」とか。emailregex.comの正規表現では許容されていません。RFC 5321で末尾のドットはNGのはずです。
GitHub
(※対象ファイル: jQuery-Validation-Engine/js/languages/jquery.validationEngine-ja.js )
stackoverflow
「Email validation using jQuery」で質問されていた投稿に対する回答が人気でした。ブログ公開現時点で682人が高評価しています。
Qiita
テストエンジニアをされている@yoshitake_1201さんの記事。
RFC 5322 & 5321に沿ったメールアドレス(local-part)のテストデータを考えてみた
ドメインについて
The top-level domains (TLDs) such as com, net and org are the highest level of domain names of the Internet. Top-level domains form the DNS root zone of the hierarchical Domain Name System. Every domain name ends with a top-level domain label.
Top-level domains
ということなので、末尾にドットはNG.
テストケース
Valid Email address | Reason |
email@domain.com | Valid email |
firstname.lastname@domain.com | Email contains dot in the address field |
email@subdomain.domain.com | Email contains dot with subdomain |
firstname+lastname@domain.com | Plus sign is considered valid character |
email@123.123.123.123 | Domain is valid IP address |
email@[123.123.123.123] | Square bracket around IP address is considered valid |
“email”@domain.com | Quotes around email is considered valid |
1234567890@domain.com | Digits in address are valid |
email@domain-one.com | Dash in domain name is valid |
_______@domain.com | Underscore in the address field is valid |
email@domain.name | .name is valid Top Level Domain name |
email@domain.co.jp | Dot in Top Level Domain name also considered valid (use co.jp as example here) |
firstname-lastname@domain.com | Dash in address field is valid |
Invalid Email address | Reason |
plainaddress | Missing @ sign and domain |
#@%^%#$@#$@#.com | Garbage |
@domain.com | Missing username |
Joe Smith <email@domain.com> | Encoded html within email is invalid |
email.domain.com | Missing @ |
email@domain@domain.com | Two @ sign |
.email@domain.com | Leading dot in address is not allowed |
email.@domain.com | Trailing dot in address is not allowed |
email..email@domain.com | Multiple dots |
あいうえお@domain.com | Unicode char as address |
email@domain.com (Joe Smith) | Text followed email is not allowed |
email@domain | Missing top level domain (.com/.net/.org/etc) |
email@-domain.com | Leading dash in front of domain is invalid |
email@domain.web | .web is not a valid top level domain |
email@111.222.333.44444 | Invalid IP format |
email@domain..com | Multiple dot in the domain portion is invalid |