5

This comment led me to RFC 5322 § 3.4.1 which reads:

An addr-spec is a specific Internet identifier that contains a locally
interpreted string followed by the at-sign character ("@", ASCII value
64) followed by an Internet domain.

The locally interpreted string is either a quoted-string or a dot-atom.

If the string can be represented as a dot-atom (that is, it contains no characters other than atext characters or "." surrounded by atext
characters), then the dot-atom form SHOULD be used and the quoted-
string form SHOULD NOT be used. Comments and folding white space
SHOULD NOT be used around the "@" in the addr-spec.

And we can see what atext is here.

atext           =       ALPHA / DIGIT / ; Any character except controls,
                        "!" / "#" /     ;  SP, and specials.
                        "$" / "%" /     ;  Used for atoms
                        "&" / "'" /
                        "*" / "+" /
                        "-" / "/" /
                        "=" / "?" /
                        "^" / "_" /
                        "`" / "{" /
                        "|" / "}" /
                        "~"

Putting this all together, does that mean that the email address email@"happy@guy.com" is actually a valid address, since the quotes allow the usage of the @ symbol?

Cory Klein
  • 1,752

2 Answers2

11

No it's not valid.

The part after the @ is the domain ("happy@guy.com" in your example).

You can't have a domain name with @ symbol in.

What are the valid characters for a domain name and how long can it be?

Also check out RFC 1035 2.3.1:

They must start with a letter, end with a letter or digit, and have as interior characters only letters, digits, and hyphen.

More info:

2

The rules for emails are so mind-bogglingly complex (and seldom followed completely correctly) that asking whether an email is valid isn't particularly helpful. Rather, it's a question of how many websites will accept your email. The more exotic an e-mail address is, the more likely it is you'll run into websites that don't accept it - even if it's in the RFC standard. For example, my.email@com is technically a valid e-mail, but you'll have a tough-as-nails time using it.

If you're an end-user, this means that you should generally pick e-mails that don't get too creative, whether or not you can. Coming up with an email that pushes the rules can make it difficult to use some websites, even if it's technically valid.

If you're maintaining software and need to validate a user's email, your best bet is to send him or her a validation email. This way, you'll be able to check whether the user's email address actually exists without having to worry about accidentally blocking users whose emails fail to conform to the RFC standards or whose emails follow edge-condition rules. (It is worth using some common-sense rules for client-side validation to help users fix typos, but you should let users override that validation if they need to.)

This question from StackOverflow discusses the issues pretty well. For what it's worth, this website lets you check whether emails are actually valid. The second comment on the page gives an example of someone with a valid e-mail address that is hard to use because of how unusual it is.


To answer your original question: No, email@"happy@guy.com" is not a valid e-mail address. Even if it were, though, I would caution against using it, and if a user claims that's his email, you should send him a validation email anyway.

Kevin
  • 712