<p dir="auto">Recently, I stumbled upon this article about validating emails:</p>
<p dir="auto"><a href="https://davidcel.is/posts/stop-validating-email-addresses-with-regex/" rel="nofollow">https://davidcel.is/posts/stop-validating-email-addresses-with-regex/</a></p>
<p dir="auto">We know that validating emails is a complex topic and depending on a lot of factors, people want something stricter than just checking for <code class="notranslate">@</code> or something simpler than an email being "right".</p>
<p dir="auto">Lots of issues have being creating along the years here about this issue (I wanted to list them all here for reference, but there are just too many of them :)).</p>
<p dir="auto">What's interesting I think (and I don't remember it being mentioned before but I might be wrong), is how HTML5 actually validates emails:</p>
<p dir="auto"><a href="https://www.w3.org/TR/html5/forms.html#valid-e-mail-address" rel="nofollow">https://www.w3.org/TR/html5/forms.html#valid-e-mail-address</a></p>
<p dir="auto">Would it be a good middle ground that we could offer as a third alternative to our users?</p>
<h3 dir="auto">Problem</h3>
<ul dir="auto">
<li>Validating email addresses is absurdly complex.</li>
<li>We've received <a href="https://github.com/symfony/symfony/issues?utf8=%E2%9C%93&amp;q=email+validation">tens of issues</a> in the past years about this validation.</li>
</ul>
<h3 dir="auto">Solution</h3>
<ul dir="auto">
<li>Let's simplify the email validator to just check that email addresses "look valid" using a good regexp.</li>
<li>If you need to validate that the email is real, send a confirmation email (by the way, do you know any serious service which doesn't send a confirmation email after signing up?).</li>
</ul>
<p dir="auto">HTML5 Standard <a href="https://html.spec.whatwg.org/multipage/forms.html#e-mail-state-%28type=email%29" rel="nofollow">proposes</a> this regexp to validate emails:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/^[a-zA-Z0-9.!#$%&amp;'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}
[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/"><pre class="notranslate"><code class="notranslate">/^[a-zA-Z0-9.!#$%&amp;'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}
[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
</code></pre></div>
<h3 dir="auto">Proposal</h3>
<ul dir="auto">
<li>Update the regexp of the EmailValidator to use the HTML5 regexp</li>
<li>Deprecate <code class="notranslate">strict</code> option</li>
<li>Deprecate <code class="notranslate">checkMX</code> option</li>
<li>Deprecate <code class="notranslate">checkHost</code> option</li>
</ul>