skeggse/isemail

Underscore not allowed in domain name, why?

Closed this issue · 3 comments

It should allow this. Some email addresses are being rejected.

I misread the title, and there were no code examples or details in the issue so I closed prematurely.

Looking at RFCs

Hm, may need to defer to @skeggse here.

I'm seeing in RFC 2181 and it appears that there is only a length-limit on domains:

any binary string whatever can be used as the label of any
resource record. Similarly, any binary string can serve as the value
of any record that includes a domain name as some or all of its value

But I am also seeing conflicting information from various people regarding RFC 1123 Sec 2.1 which specifies that hostnames follow the LDH (letter, digit, hyphen) rule.

This is operating as expected. I should've more careful about terminology, but what you're describing is a syntax error. Domain names in the domain name system have few restrictions. Host names as used in internet protocols are limited to LDH.

RFC 5321 explicitly requires, per section 4.1.2, that SMTP servers which receive a command with invalid character codes (RFC 5321 in the same section gives the underscore as an example) MUST reject the command with a 501 response.