Is email@"happy@guy.com" a valid email address?

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

Posted 2013-09-26T19:22:09.253

Reputation: 1 232

Answers

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:

Ƭᴇcʜιᴇ007

Posted 2013-09-26T19:22:09.253

Reputation: 103 763

Interesting. Letters, digits, and hyphens are all atext. So I wonder what kind of domain would require quotes as specified in 3.4.1? – Cory Klein – 2013-09-26T19:44:30.133

Ah, I think I have been reading it incorrectly. When mentioning the quotes it is talking about the text before the @ sign and domain. So maybe "email@email"@happyguy.com is a valid email address? – Cory Klein – 2013-09-26T19:45:43.170

1From RFC 5322 regarding the domain name: "Note: A liberal syntax for the domain portion of addr-spec is given here. However, the domain portion contains addressing information specified by and used in other protocols (e.g., [RFC1034], [RFC1035], [RFC1123], [RFC5321]). It is therefore incumbent upon implementations to conform to the syntax of addresses for the context in which they are used." – Ƭᴇcʜιᴇ007 – 2013-09-26T19:52:10.993

1

in general Wikipedia's descriptions are a little less cryptic than the RFC's. Check out http://en.wikipedia.org/wiki/E-mail_address#Local_part

– Ƭᴇcʜιᴇ007 – 2013-09-26T20:00:03.950

You could use "H@ppy_guy"@domain.tld as mail address, or "Happy@guy..demo"@domain.tld. It would be legal but many websites would break on it. Most do not even accept other legal uses such as my_name+spam_from_blah@domain.tld. I think they would also break on the other examples. – Hennes – 2013-09-26T20:04:53.210

@Hennes On the bright side, that would probably also break many spambots... – Tobias Kienzler – 2013-09-27T10:39:22.670

Yup. That us why I use it. In the past my mail averaged 10 real mail per day, and 131 spams per day (Spam filtering turned off for a month in order to gather statistics). So I used "mynane+thiswebsiteused@mydomain.tld". Sadly that does not work with some websites which are made by amateurs, such as VISA and VMware. (Worse, it used to work with vmware, they later 'improved' the site preventing my from logging in or resetting my password). – Hennes – 2013-09-27T13:13:23.320

2Sometimes you can work around this because the email address input mis-validator is on the actual webpage and then you can use things like firebug or webscarab to edit the script which incorrectly validates stuff. It is annoying though. – Hennes – 2013-09-27T13:14:21.030

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

Posted 2013-09-26T19:22:09.253

Reputation: 684