The only useful email validation is “can I get an MX from that” and “does it understand what I’m saying in that SMTP”. Anything else is someone that have too much free time.
DmMacniel@feddit.de 10 months ago
When you insist on implementing your own email address validation…
cley_faye@lemmy.world 10 months ago
cashews_best_nut@lemmy.world 10 months ago
It’s easier to Google “email regex [language]” and copy the first result from stack overflow.
vithigar@lemmy.ca 10 months ago
Definitely a timesaver. Much faster to get incorrect email validation that way then to try building it yourself.
Archer@lemmy.world 10 months ago
Skip the building step and go straight to pulling your hair out over why it’s not working! Efficiency!
Katana314@lemmy.world 10 months ago
That probably lead to this exchange.
Stack Overflow is useful, but…it needs more than a little parsing for useful answers.
felbane@lemmy.world 10 months ago
I know (hope) you’re being facetious, because the objectively best way to do email validation is to send a fuckin email to the provided address.
AnAngryAlpaca@feddit.de 10 months ago
To be valid, the email just has to match [anything@anything]. ,🙃@localhost can be perfect legal if localhost supports utf8 in usernames.
kamenoko@sh.itjust.works 10 months ago
Or implement a validator from a known good library.
KickMeElmo@sopuli.xyz 10 months ago
I’ve encountered this because my domain has a hyphen in it. Very irritating.
TheBat@lemmy.world 10 months ago
@spider-man.net?
aard@kyu.de 10 months ago
I’m not aware of any correct email validations. I’m still looking for something accepting a space in the localpart.
Also a surprising number of sites mess with the casing of the localpart. Don’t do that - many mailservers do accept arbitrary case, but not all. MyName@example.com and myname@example.com are two different mail addresses, which may point to the same mailbox if you are lucky.
CosmicTurtle@lemmy.world 10 months ago
The only correct regex for email is:
.+@.+
So long as the address has a local part, the at sign, and a hostname, it’s a valid email address.
Whether it goes somewhere is the tricky part.
xantoxis@lemmy.world 10 months ago
Sorry, this is not a correct regex for an email address.
Sending using ‘mail’ on a local unix system? You only need the local part.
STOP VALIDATING NAMES AND EMAIL ADDRESSES. Send a verification email. Full stop. Don’t do anything else. You really want to do this anyway, because it’s a defense against spam.
stardreamer@lemmy.blahaj.zone 10 months ago
*Gasp* the registration is coming from inside the data center!
Turun@feddit.de 10 months ago
I think it’s fair to prevent users from causing mail sent to your internal systems. It probably won’t cause any issues getting mail to the machine inbox for (no domain name), but it reasonably makes security uneasy.
elrik@lemmy.world 10 months ago
Yes, but no. Pretty much every application that accepts an email address on a form is going to turn around and make an API call to send that email. Guess what that API is going to do when you send it a string for a recipient address without an @ sign? It’s going to refuse it with an error.
Therefore the correct amount of validation is that which satisfies whatever format the underlying API requires.
For example, AWS SES requires addresses in the form UserName@[SubDomain.]Domain.TopLevelDomain along with other caveats. If the application is using SES to send emails, I’m not going to allow an input that doesn’t meet those requirements.
tomaThomas@lemmy.world 10 months ago
Here’s my address: @@@@@
laurelraven@lemmy.blahaj.zone 10 months ago
And this right here is a great example of why simple basic RegEx is rarely adequate
At the very least, should be something like
^[^@\s]+@([^@\s.]+\.)+[^@\s.]+$
I’m like 99% sure I missed at least a few cases there, and will say “please don’t use this for anything production”
uid0gid0@lemmy.world 10 months ago
You should be able to double quote the local part and use the space. “like this”@email.net. Good luck getting that through a validator though.
MonkderZweite@feddit.ch 10 months ago
When you insist on implementing your own
email address validationregex string…jpeps@lemmy.world 10 months ago
DeltaTangoLima@reddrefuge.com 10 months ago
I have my own domain that uses a specific 2-letter ccTLD - it’s a short domain variation of my surname (think “goo.gl” for Google). I’ve been using it for years, for my email.
Over those years, I have discovered an astonishing number of fuckheaded organisations whose systems insist I should have an email address with a “traditional” TLD at the end.
stickmanmeyhem@lemmy.world 10 months ago
A few years back I bought a .family domain for my wife and I to have emails at ourlastname.family That lasted a week because almost every online service wouldn’t accept it. Now we have a .org
CosmicTurtle@lemmy.world 10 months ago
Doesn’t surprise me one bit. I’ve noticed that a lot of websites will only accept
.com
and a few will only accept email addresses from popular providers (Gmail, Hotmail, outlook, etc.)My guess is that it’s trying to reduce spam and fake account generation.
deweydecibel@lemmy.world 10 months ago
Thus preventing the growth of any small providers and further entrenching Microsoft, Google, Apple, and a handful of others as the only “viable” options.
Blamemeta@lemm.ee 10 months ago
Yeah, that’s it pretty much.Like 99% of your legitimate users are going to be standard gmail/yahoo/hotmail/etc. You see a user from ten minute mail, it’s probably some shady shit.
MBM@lemmings.world 10 months ago
Feels very relevant to the fediverse, with how people tend to compare it to email.
frozen@lemmy.frozeninferno.xyz 10 months ago
I went with .io specifically for this. It doesn’t look special or anything, it’s just cheaper than .org and accepted anywhere I’ve tried, so far.
freehugs@lemmy.world 10 months ago
What registrar do you use? Last time I checked .io domains where like 4x the price of a .org
NightAuthor@lemmy.world 10 months ago
I hate it.
PM_Your_Nudes_Please@lemmy.world 10 months ago
Same. There are a lot of sites that just outright refuse to accept my email address that I’ve had for years, because it’s not a .com TLD.
lunarul@lemmy.world 10 months ago
One of my first email addresses was @k.ro (a free email provider many many years ago) and many websites thought a valid second-level domain name cannot be just one letter
laurelraven@lemmy.blahaj.zone 10 months ago
I’d love to know where they got the idea that the spec doesn’t allow that…