4 ms·
Assuming that running the regex is much faster than sending an email, it would probably be much less server load to check the regex and never send X% of emails,
by joshuahedlund 13y ago
Assuming that running the regex is much faster than sending an email, it would probably be much less server load to check the regex and never send X% of emails, unless X is extremely small.
(Looking up and implementing a regex) * 1 + (running the regex) * (every email) + (sending email) * (every valid email) < (sending email * every email)
Also, this post only considers the signup/activation use case. If you're getting an email for ecommerce to send an order confirmation, you want to know if the email might be invalid before the user completes the order and you try to send it.
- arkitaip 13y agoYou still need to confirm the validity of the email request by sending an confirmation email, so you might as well just check for '@' and let your confirmation system handle the rest.
- SideburnsOfDoom 13y agoThis assumes that you get the regex 100% right and never lose a user by rejecting a valid email address. This is much harder than it seems ( http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html ), and is no guarantee an valid email address that is in use, as the article makes clear. After some very basic checks, e.g. "contains at at least 3 chars, one of which is an @", you should Just. Send. The. Email. Who bothers to type in a complex but invalid email address? The overwhelmingly common failure modes are: 1) Nothing entered at all. The basic check catches this. 2) Deliberate invalid email address. e.g. homer.j.simpson@springfieldnuclear.com - a regex will not catch this. 3) Typo in email address. e.g. john.smith@gmial.com - a regex will not catch this either. The regex has downsides and complexity, but essentially no benefit.
- tomjen3 13y agoArguably 3 should be covered by user prompt.
- baudehlo 13y agoPlease don't quote that RFC-822 regexp when arguing this. That's for the contents of mail headers (which can include comments and so on), not an actual valid email address. A regexp for validating RFC-2821 email addresses is actually fairly simple.
- SideburnsOfDoom 13y agoWhichever RFC it is, it is not so simple that everyone gets it right. For innstance, a significant percentage of websites don't let you register email addresses containing a plus sign in the name, e.g. john.smith+foo_bar@host.com
- deleted 13y ago[deleted]