truemail-rb / truemail

🚀 Configurable framework agnostic plain Ruby 📨 email validator/verifier. Verify email via Regex, DNS, SMTP and even more. Be sure that email address valid and exists.

Home Page:https://truemail-rb.org/truemail-gem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ISSUE] MX validation succeeds with A record validation

ckhsponge opened this issue · comments

Issue Description

"gmail.con" is a common typo in email addresses. The domain lacks a MX record but has an A record. I would desire MX validation to return false but it succeeds. Perhaps there's a reason to accept the A record I'm not understanding. Thanks.

Complete output when running truemail, including the stack trace and command used
Truemail.valid?("abc@gmail.con", with: :mx) -> true
Truemail.valid?("abc@stanford.ed", with: :mx) -> true

Hi, @ckhsponge Truemail MX lookup based on RFC 5321. It consists of 3 substeps: MX, CNAME and A record resolvers. The point of each resolver is attempt to extract the mail servers from email domain. If at least one server exists that validation is successful. Iteration is processing until resolver returns true.

https://slides.com/vladislavtrotsenko/truemail/#/0/9

So, as you can see this behaviour is not a bug. But you can add to blacklisted domains all 'mail typo domains' which you consider necessary. As proposition maybe make sense to add ability configure mx validation flow in next release. What you think?

Looks like you are correct! I didn't realize email could be delivered without a MX record.

Thanks for creating the gem.

You're welcome, @ckhsponge. I will add ability to configure only mx records validation flow in next release.

@ckhsponge, I have implemented ability to use not RFC MX lookup flow: #80, and now this option is available in 1.7.0 release. Cheers!

Thanks for implementing! I think this could be very useful for strict implementations. We currently want to avoid false negatives so will probably just use a blacklist for now.