Answer the question
In order to leave comments, you need to log in
Can there be such a domain name or subdomain or mail?
I am writing a universal regular expression for email validation and the following questions arose:
1. There are domains with Cyrillic in the name, for example https://peter.rus and, as I understand it, there may be an email address [email protected], but can there be mail with Cyrillic in the name itself, for example [email protected]?
2. Can domains/subdomains start or end with "-" or "_"?
For example http://-toster.com/ or http://toster-.com/ or http://_toster.com/ or http://toster_.com/
3. Can mail names start or end with "- " or "_"?
For example [email protected] or [email protected] or [email protected] or [email protected]
4. Can email names contain multiple consecutive underscores "_"?
For example [email protected]
5. Can a dot appear in the mail name after or before "-" or "_"?
For example [email protected]
6. Can a dot appear in the mail name after 1 character?
For example [email protected]
Answer the question
In order to leave comments, you need to log in
1. [email protected] will work almost everywhere (but the punycode address of the domain may be displayed somewhere), provided that the domain is correctly encoded in punycode when sending, users of old mail programs may have problems writing to this address. [email protected] will only work if all mail servers and clients between the sender and recipients support RFC6531/RFC6532, in practice such addresses are not used and will not be used in the foreseeable future. instant transition of the entire Internet to UTF-8 is impossible, and what to do if the respondent does not support UTF-8 is not clear (there is no analogue of punycode for local-part). But I would not recommend using the peter.com domain for mail, because. such a domain uses mixed script and does not pass the Unicode (aka TR39) security requirements.
2. According to RFC 952/1035, a hostname starts with a letter and ends with a letter or number, and can contain numbers, letters, and - inside. RFC 1123 additionally allows a name to begin with a number. But technically, the DNS protocol supports any characters, even 8-bit ones, and even non-standard names can be opened in browsers. But, of course, it is more correct to focus on the standard.
3,4,5,6. Everything is interesting with local-part, the situation is reversed. According to the standard, there can be almost anything, but inside the string in double quotes (quoted-string). In fact c quoted-string addresses are not used and are not usually accepted. Without quoted string, a lot of things are also allowed, there can be any numbers, letters, symbols "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "/" / "=" / "?" / "^" / "_" / "`" / "{" / "|" / "}" / "~" in any sequence, the character "." is also allowed. Therefore, all your addresses are valid. BUT you cannot start and end local-part with a dot and use two dots in a row (this is in some way a bug in RFC 2821/2822 and later related to formalized notation, which was noticed rather late, RFC 821/822 allowed two dots in a row). In practice, I would not recommend using any "strange" addresses about which there are doubts, because. not everything that is allowed by the standard is in fact accepted by everyone.
Answers to these questions and more
https://en.wikipedia.org/wiki/Email_address#Local-part
https://tools.ietf.org/html/rfc952
https://tools.ietf.org/html/rfc5992
https://tools.ietf.org/html/rfc6530
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question