| ▲ | win311fwg 3 hours ago | |||||||
> The rules of email validation are not remotely well defined! RFC 5322 fully defines the structure. > IMO the industry consensus is never to "validate" email addresses syntactically That is true, but not because it isn't well defined, but because it is hard to get right. Keep in mind that most developers don't even know what a property-based test is, and of those that do, only a small subset of them know how to use them. If you find any testing around it at all, which is a stretch to begin with, you will be lucky to find more than a small set of common addresses without any care or concern for the complex edge cases that lead to problems like I have had as a user in the past. Encouraging developers to only validate for the presence of @ means that there is no additional room to screw things up. But better than to rely on gimping your code to deal with developers is to use the tools at your disposal. > and to verify the email address by emailing it an activation code. That may also be beneficial, but not for the same reason. Not all CRUD use-cases fit that mould. | ||||||||
| ▲ | dfabulich 3 hours ago | parent | next [-] | |||||||
Don't forget RFC 5321! But the RFCs are ignored in practice by all popular mail servers. There are email addresses that work in practice that don't comply with the RFCs, and there are email addresses that the RFCs permit that don't work in practice. (This happens with a lot of standards; sometimes people just ignore them and do their own thing. Something similar has happened with SVGs.) If you write a formal verification of a syntactical email validator that ensures that all/only RFC-compliant email addresses are valid, you'll have completely wasted your time. Don't do it. Just check for at least one @ sign, and email the address to test it. (This is a perfect example of the trap of formal verification.) | ||||||||
| ||||||||
| ▲ | Analemma_ 2 hours ago | parent | prev [-] | |||||||
I'm speaking from painful experience here: if you assume RFC 5322 has anything whatsoever to do with how email addresses actually work in the wild, you're in for a world of hurt. Popular email providers don't give a shit what RFC 5322 says, and you can't either if you want to have any hope of actually sending and receiving mail. Test messages are the only way to validate an email address, period. | ||||||||
| ||||||||