title: What are the valid characters in the domain part of e-mail address?
body: <h1>Intention</h1>
  <p>I'm trying to do some minimal very minimal validation of e-mail addresses, despite seeing a lot of advice advising against doing that. The reason I'm doing this is that spec I am implementing requires e-mail addresses to be in this format:</p>
  <p><code>mailto:&lt;uri-encoded local part&gt;@&lt;domain part&gt;</code></p>
  <p>I'd like to simply split on the starting <code>mailto:</code> and the final <code>@</code>, and assume the &quot;local part&quot; is between these. I'll verify that the &quot;local part&quot; is URI encoded.</p>
  <p>I don't want to do much more than this, and the spec allows for me to get away with &quot;best effort&quot; validation for most of this, but is very specific on the URI encoding and the <code>mailto:</code> prefix.</p>
  <h1>Problem</h1>
  <p>From everything I've read, splitting on the <code>@</code> seems risky to me.</p>
  <p>I've seen a lot of conflicting advice on the web and on Stack Overflow answers, most of it saying &quot;read the RFCs&quot;, and some of it saying that the domain part can only be certain characters, i.e. <code>1-9</code> <code>a-z</code> <code>A-Z</code> <code>-.</code>, maybe a couple other characters, but not much more than this. E.g.:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/2049502/what-characters-are-allowed-in-email-address">What characters are allowed in an email address?</a></li>
  </ul>
  <p>When I read various RFCs on domain names, I see that <a href="http://www.ietf.org/rfc/rfc822.txt" rel="nofollow noreferrer">&quot;any CHAR&quot; (<code>dtext</code>)</a> or <a href="https://www.rfc-editor.org/rfc/rfc5322#page-18" rel="nofollow noreferrer">&quot;any character between ASCII 33 and 90&quot; (<code>dtext</code>)</a> are allowed, which implies <code>@</code> symbols are allowed. This is further compounded because <a href="https://www.rfc-editor.org/rfc/rfc5322#page-11" rel="nofollow noreferrer">&quot;comments&quot; are allowed in parens <code>(</code> <code>)</code> and can contain characters between ASCII 42 and 91</a> which include <code>@</code>.</p>
  <p><a href="https://www.rfc-editor.org/rfc/rfc1035#page-8" rel="nofollow noreferrer">RFC1035 seems to support the letters+digits+dashes+periods requirement</a>, but <a href="https://www.rfc-editor.org/rfc/rfc5322#page-18" rel="nofollow noreferrer">&quot;<strong>domain literal</strong>&quot; syntax in RFC5322</a> seems to allow more characters.</p>
  <p>Am I misunderstanding the RFC, or is there something I'm missing that disallows a <code>@</code> in the domain part of an e-mail address? Is &quot;domain literal&quot; syntax something I don't have to worry about?</p>