Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
The line of code you came for: https://github.com/ruby/ruby/blob/master/lib/uri/mailto.rb#L...
There are basically three levels of address checking:
1) You need to validate an email field for login or a website - checking for an @ mark with some text before and at least one . after the @ will do for this.
2) You need to do some sort of address validation, library regexps like this will do for 99.9...% of these.
3) You are building an email handling system which needs to actually support the RFCs, in which case regexp will not handle what you need, and you need to use a proper parser, like https://github.com/mikel/mail/tree/master/lib/mail/parsers
Ref: I am the original author of the Ruby mail gem.
The most helpful thing I've used in the real world is something that looks for common typographical errors, even if the email is technically valid.
Like, if the user types "[email protected]", it pops a dialogue asking "Did you mean "[email protected]". But lets them keep what they typed, or do a different fix if needed.
I found some JS called "mailcheck": https://github.com/mailcheck/mailcheck
There are updated clones that use react, vue, etc, instead of jquery.
With a working ecommerce site, this improved the percentage of correct emails more than anything else I tried, and I had tried many things. Because it's a bad situation when you've taken someone's money and have nothing other than a shipping address to contact them if something goes wrong (bad shipping address, out of stock situation, etc).