News for hackers. Stuff that matters.
Re:Show HN: Deep Email Validator by runlevel1 on Wednesday December 16, 2020 @09:56AM (#25443241)
Presence of an MX record should _not_ be used as a litmus test for a valid email domain.

RFC 5321 section 5 specifies that you lookup the MX and, if absent, use the A/AAAA record. I'm simplifying a bit, but that's the gist of it.

Using just the A record is more common than you might expect.

[1]: https://tools.ietf.org/html/rfc5321#section-5

Re:Show HN: Deep Email Validator by nickjj on Wednesday December 16, 2020 @07:28AM (#25441749)
The first line mentions:

> Validates email looks like an email i.e. contains an "@" and a "." to the right of it.

But what about emails coming from a hostname without a dot, or a TLD without a subdomain?

Even the HTML email field supports emails without a dot after the @ because it's technically valid.

Re:Show HN: Deep Email Validator by chipsa on Wednesday December 16, 2020 @08:23AM (#25442185)
You could do it for a TLD without a subdomain. The TLD "tt" does in fact have MX records. But it's a very rare case that a TLD does, and prohibited for any of the new TLDs.

For non-FQDN hostnames, it's kinda pointless, as you can only use that on your own domain. So if you were to do that, just make up your own pseudo-TLD like ".x" with an alternate DNS system. You could even have it point to the regular DNS system through CNAMEs.

Re:Show HN: Deep Email Validator by pul on Wednesday December 16, 2020 @09:55AM (#25443216)
Re:Show HN: Deep Email Validator by ketamine__ on Wednesday December 16, 2020 @07:50AM (#25441904)
I understand it's technically correct but this is a solution no one wants. I recently spent time fixing this in application.
Re:Show HN: Deep Email Validator by tyingq on Wednesday December 16, 2020 @08:27AM (#25442221)
Sendmail also still supports uucp bangpaths as an email address: https://www.sendmail.org/~ca/email/doc8.12/cf/m4/uucp_mailer...
Re:Show HN: Deep Email Validator by Veen on Wednesday December 16, 2020 @07:48AM (#25441896)
Yeah, looks like they're doing super-naive address validation:

https://github.com/mfbx9da4/deep-email-validator/blob/master...

Re:Show HN: Deep Email Validator by Arnt on Wednesday December 16, 2020 @08:06AM (#25442020)
OTOH, that code looks as if it'll find the vast majority of the problems more careful analysis could find, both simply and without bad consequences.

All that happens if that naïve code fails is that it does an MX lookup that's bound to fail, and then the code returns a bad error message ("couldn't find MX" instead of more properly "syntax error in domain part").

Re:Show HN: Deep Email Validator by stevekemp on Wednesday December 16, 2020 @09:18AM (#25442726)
If an MX record isn't present you can fall back on the A-record.

(If, and only if, no MX record for the domain is present, treat the domain as if it had an MX record with the given domain as the target hostname and a preference value of 0)

Re:Show HN: Deep Email Validator by Arnt on Wednesday December 16, 2020 @11:30AM (#25444502)
If you want to be pedantic... not in the relevant case, no. In the relevant case (the domain is syntactically invalid but the naïve check didn't discover that) the response without MX RRs already tells you that there won't be an A (or AAAA).
Re:Show HN: Deep Email Validator by IgorPartola on Wednesday December 16, 2020 @08:22AM (#25442173)
foo@2001::01 is a valid email address, no? So is using the alternative dotless representation of the IPv4 addresses.
Re:Show HN: Deep Email Validator by chrismorgan on Wednesday December 16, 2020 @09:52AM (#25443172)
Per the RFC 5322 addr-spec grammar production, it’s actulaly not: colons aren’t permitted in regular domain name syntax; you need to use the domain literal form: foo@[2001::01]. Same deal with HTTP URLs, IPv6 localhost port 8080 is http://[::1]:8080/.
Re:Show HN: Deep Email Validator by jcranmer on Wednesday December 16, 2020 @11:27AM (#25444458)
foo@[IPv6:2001::01], since it's an IPv6 address. Without the IPv6 prefix, it must be an IPv4 address.
Re:Show HN: Deep Email Validator by chrismorgan on Wednesday December 16, 2020 @12:43PM (#25445623)
Ah hah, https://tools.ietf.org/html/rfc5321#section-4.1.3 defines this. I had tried briefly to find something, but not very hard, and so incorrectly guessed it was like HTTP URLs. Thanks for the correction, this is good to know. With that, I also note that exotic IPv4 address formats (such as the 32-bit integer representation) are excluded in that grammar.
Re:Show HN: Deep Email Validator by m-p-3 on Wednesday December 16, 2020 @08:36AM (#25442305)
At least they aren't invalidating email addresses with the plus sign like some registration forms I encountered out there..
Re:Show HN: Deep Email Validator by madsbuch on Wednesday December 16, 2020 @09:25AM (#25442813)
For most applications email validation is really not nesecarry. instead a service can rely on email verification. If the address is invalid, mails sent to it will never arrive at a destination.
Re:Show HN: Deep Email Validator by mewpmewp2 on Wednesday December 16, 2020 @10:27PM (#25452090)
It is good UX to let user immediately know if they enter a typo or an e-mail that is bound to fail. It is a real waste of time if user enters wrong e-mail and keeps refreshing inbox and spam for the following 5 minutes and still unsure afterwards whether they put wrong e-mail or the server just wasn't working correctly.
Re:Show HN: Deep Email Validator by mfbx9da4 on Monday December 21, 2020 @08:28AM (#25494696)
Also you will end up fucking your reputation by sending out emails to bad mailboxes all day long
Re:Show HN: Deep Email Validator by huhtenberg on Wednesday December 16, 2020 @10:17AM (#25443538)
Notably, this doesn't work for sending out purchase receipts.
Re:Show HN: Deep Email Validator by conradludgate on Wednesday December 16, 2020 @01:57PM (#25446784)
One of the big problems we had at my old job. We were selling event tickets, the even we were selling for were sold in batches and usually sold out in minutes, so people would rush to purchase. We saw so many gnail.com addresses and people complained about not receiving their tickets
Re:Show HN: Deep Email Validator by bo1024 on Wednesday December 16, 2020 @09:50AM (#25443143)
You might save a little bit of confusion by calling it an email "address" validator.
Re:Show HN: Deep Email Validator by sdfhbdf on Wednesday December 16, 2020 @09:16AM (#25442693)
Hopefully this doesn't get used in some kind of registration flow in full since for example if you register with an aliased address, or you have a catchall address or email is just proxied the SMTP checks would fail.
Re:Show HN: Deep Email Validator by huhtenberg on Wednesday December 16, 2020 @09:25AM (#25442805)
Why would they fail?

It opens an SMTP connection and runs through the handshake. If this fails then, it will fail with a real delivery just the same.

It's still a bad test to do, but for other reasons.

Re:Show HN: Deep Email Validator by edoceo on Wednesday December 16, 2020 @09:51AM (#25443158)
What are the other reasons?

On signup for my app we validate like this, with MX and SMTP check - before sending a account verify message

Re:Show HN: Deep Email Validator by huhtenberg on Wednesday December 16, 2020 @10:16AM (#25443523)
SMTP checks need to be run from the actual mail server/cluster that will be sending emails, using the exact same EHLO greeting, etc. Otherwise you may get both false positives and negatives due to IP blocks and mail header filters on the receiving end. That's without getting into timeouts and remote-side enforced TLS.
Re:Show HN: Deep Email Validator by jedberg on Wednesday December 16, 2020 @02:07PM (#25446937)
There is exactly one right way to validate an email: send a message to it.

Email is a very old protocol with a lot of hacks and backwards compatibility. At this point, pretty much any string could be a valid email address. You can certainly run a bunch of tests and get a decent signal, but it's a lot of work, and if you reject an email address without testing it you're going to cause someone some trouble at some point. It's a lot easier and more accurate to just accept the string and try to send email to it.

Re:Show HN: Deep Email Validator by mfbx9da4 on Monday December 21, 2020 @08:19AM (#25494633)
It’s not a lot of work if you use a library. You will still need to do verification but saves you destroying your email domain reputation
Re:Show HN: Deep Email Validator by amaurymartiny on Wednesday December 16, 2020 @07:34AM (#25441803)
Interesting, I wrote a similar tool some time ago, in Rust: [link redacted]

I'm using a similar technique to check deliverability, i.e. parsing SMTP responses.

Re:Show HN: Deep Email Validator by 293984j29384 on Wednesday December 16, 2020 @09:54AM (#25443200)
I'm not a big fan of denying disposable email services. For that reason, I'll pass.
Re:Show HN: Deep Email Validator by mfbx9da4 on Monday December 21, 2020 @08:20AM (#25494636)
Lol
Re:Show HN: Deep Email Validator by that_guy_iain on Wednesday December 16, 2020 @07:53AM (#25441923)
I bet this would fail on my catch all email since it checks if the mailbox exists, right?
Re:Show HN: Deep Email Validator by holstvoogd on Wednesday December 16, 2020 @01:36PM (#25446415)
Not 100% sure, but I expect it asks the server if mail to an address is deliverable. I recently was doing some testing directly talking SMTP to a server and recall a special check command. IIRC it said it check if the server would accept mail for an address. So I don’t think it would fail on a catch all.

Assuming this uses that technique.

Re:Show HN: Deep Email Validator by ketamine__ on Wednesday December 16, 2020 @07:48AM (#25441893)
How does it handle timeouts?
Re:Show HN: Deep Email Validator by mfbx9da4 on Monday December 21, 2020 @08:21AM (#25494650)
It has a hard coded timeout. The user can try again if some unrelated timeout error