Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating common email typos without MX/network lookup, using public suffix gem #78

Closed
eliotsykes opened this issue May 21, 2021 · 1 comment

Comments

@eliotsykes
Copy link
Contributor

eliotsykes commented May 21, 2021

I'm researching preventing common TLD and public suffix typos like "mailbox@gmail.cpm", whilst avoiding an MX lookup for performance reasons.

One proposed solution is to check the address domain against the public suffix database using strict validation:

PublicSuffix.valid?("gmail.cpm", default_rule: nil)
# => false

PublicSuffix.valid?("gmail.com", default_rule: nil)
# => true

Do you think this is something that would be a worthwhile addition to the email_address gem, perhaps as a host_validation: :public_suffix option?

@eliotsykes eliotsykes changed the title Validating common email typos without MX, using public suffix gem Validating common email typos without MX/network lookup, using public suffix gem May 21, 2021
@eliotsykes
Copy link
Contributor Author

eliotsykes commented May 21, 2021

Closing this issue as I've learned more about the public suffix database, and tried it against some real emails, its validation throws up some false negatives.

For example "@gov.bm" and "@sa.gov.au" are valid email domains but the public suffix db will flag them as invalid.

Possibly the public suffix db could be used only as a positive signal:

  • If an email domain passes public suffix validation, treat is as valid
  • If an email domain fails public suffix validation, only then perform an MX lookup (minimizes network trips, consider caching the result)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant