5 ms·
No, no, no, no. Normal people don’t always use the email field properly. The might put the username in the email field and the email in the username. Just check
by epochwolf 14y ago
No, no, no, no. Normal people don’t always use the email field properly. The might put the username in the email field and the email in the username. Just check for an @. There is no email in the world outside your server that you can sent to without an @.
- smosher 14y agoJust for fun: https://en.wikipedia.org/wiki/Bang_path#UUCP_for_mail_routing https://en.wikipedia.org/wiki/Bang_path#UUCP_for_mail_routin... But yeah, that's effectively dead and you probably don't want to try sending mail that way.
- eropple 14y agoHe'd have to have bang routes set up on his mail server for that. =) So it's not just effectively dead, it's dead-dead.
- smosher 14y agoI am chose my phrasing for the very reason that it's merely incredibly unlikely and not at all impossible. I've even sent mail with bang-paths post-2000 just to confound the recipient, though it is a rare network that would accommodate that today. Edit: punctuation.
- davidcelis 14y agoI did that for a time (which I mention in the article), but it's still a superfluous check on top of an activation email. If your users are typing the wrong values into your registration form, perhaps you need better labeling or placeholder text? Display an error that the activation email couldn't be sent. But why add superfluous checks?
- aaronpk 14y agoKnowing whether the email was sent is not always something you can do synchronously. A simple check for an "@" sign would go a long way to avoiding bounced mail notifications from usernames being entered in email address fields.
- davidcelis 14y agoYes, agreed (and I mention this at the end of the article as well) and I still use the /@/ regex often. But a good UI on the registration form can go a long way in alleviating the "switching the email address and username fields" problem.
- spc476 14y agoOne addtional check---see if there's an MX or an A record on the portion after the "@".
- IbJacked 14y ago
- eli 14y agoI totally agree. The one other thing I might add is to check for commas, since they are never valid in an email address and "something,com" is a common typo.
- ken 14y agoBy my reading of RFC 822, commas are technically valid, as long as they are properly quoted, as in: "Doe, John"@example.com Of course, whether any email server actually accepts that is a different story.
- eli 14y agoAt the risk of sounding like a hyprocrite since I just advocated for minimal validation of emails... that is a nonissue. Nobody actually does that. Anyway, the regexp I use is /.+@.+\..+/ which supports the address you describe, but (usually) catches the relatively common mistake of user@yahoo,com
- jph 14y agoCommas can be valid and our servers manage them correctly.
- jph 14y agoYou've got it backwards-- the use case is to catch things like "grandma@aol" and "foo@@bar,com". If we just check for "@" then we'd send email into the void. Instead, we check for more specifics, and we prompt the user to correct the email address. This improves our response rate about 2% which for us is significant.
- dekz 14y agoBut grandma@aol is a valid email address (if aol were to become a proper TLD with an MX record).
- jph 14y agoHahah yes you're correct. We do client-side auto-suggest on email validation, so we can ask "Did you mean to type grandma@aol.com"? We have seen a real email address without any dot, and it routes successfully to a TLD MX exactly like you describe so yes, it does happen. :)
- nickzoic 14y agoHere's another thought, just off the top of my head: get people to sign up by sending an email to "subscribe@example.com". You can include that as a "mailto:" link and many browsers will deal with it correctly. There's very good odds that the email they send will have their "From:" (or "Reply-To:") address correctly set. Then just have an email autoresponder which emails them back a link with a token in it, when they click on that it'll take them to a page to create their account, with their email address already filled in by the token.
- eru 14y agoSending people to their emailclient would probably decrease conversion too much.
- nickzoic 14y agoYeah, maybe. But you're going to have to send them there some time to do the "confirm email" thing, I was just thinking perhaps get that over and done with upfront. Ideally, all this would be done away with by OpenID or client-side certificates or something along those lines. The whole password-and-email-in-case-you-forget-it paradigm is broken, really.
- n09n 14y agoThat's not true either. I don't know how it's set up other than that we use exchange, but on our internal network, you can send an email to someone's firstinitiallastname (the part that is before the @ for external senders) and it will go through. So on our production servers, I need the @, but on our dev/text servers, I don't. And no, the domain is not appended to the address before sending. That's the part I actually know about.
- richardkeller 14y agoIt's common practice to allow unqualified emails addresses (ie. without the @domain.tld) from local sources since it's trivial to look up against your own user list. Depending on the MTA, the domain may or may not be appended, but often the local organisation's default domain is implied. However, this shouldn't work when routing mail via external MTAs that have no knowledge of your organisational structure.