valid_email2 icon indicating copy to clipboard operation
valid_email2 copied to clipboard

Non disposable mail marked as disposable based on MX record

Open notentered opened this issue 1 year ago • 1 comments

Hi :)

I have an email address, which I'm checking against .disposable?

  • It returns true even that I'm 100% sure it is not.
  • The domain is not in the list so, disposable_domain? returns false (this will be my current workaround, to check against disposable_domain? instead of 'disposable?')
  • disposable_mx_server? returns true

Without sharing the exact email here, after short investigation I found that the domain have an mx_record alt2.aspmx.l.google.com.com. So, if we run ValidEmail2.disposable_emails.find { |d| 'alt2.aspmx.l.google.com.com'.end_with?(d) } we receive:

ValidEmail2.disposable_emails.find { |d| 'alt2.aspmx.l.google.com.com'.end_with?(d) }
=> "com.com"

Checking all the MX records for that specific email, I also receive:

ValidEmail2.disposable_emails.find { |d| 'aspmx2.googlemail.com'.end_with?(d) }
=> "mail.com"

and

ValidEmail2.disposable_emails.find { |d| 'aspmx3.googlemail.com'.end_with?(d) }
=> "mail.com"

I'm not sure is this is an expected behavior. But as the exact email is a valid/active/non-disposable, I thought there may be something off.

Thank you!

notentered avatar Apr 26 '23 10:04 notentered

Hello.

I'm trying to reproduce this but aren't able to do so.

[13] pry(main)> email = ValidEmail2::Address.new("[email protected]")
=> #<ValidEmail2::Address:0x0000000111b52d10 @address=#<Mail::Address:2240 Address: |[email protected]| >, @dns_timeout=5, @parse_error=false, @raw_address="[email protected]">
[14] pry(main)> email.instance_variable_set(:@mx_servers, ["aspmx3.googlemail.com"])
=> ["aspmx3.googlemail.com"]
[15] pry(main)> email.disposable?
=> false
[16] pry(main)> email.instance_variable_set(:@mx_servers, ["alt2.aspmx.l.google.com.com"])
=> ["alt2.aspmx.l.google.com.com"]
[17] pry(main)> email.disposable?
=> false

As you can see here: https://github.com/micke/valid_email2/blob/bd01c20900941de4e018a98a692f6ec5e64cacbb/lib/valid_email2/address.rb#L123 The gem doesn't only do a end_with?, it also checks that the domain is a subdomain, not only ends with the domain with the regex: /\A(?:.+\.)*?#{domain}\z/.

What version of the gem are you using?

micke avatar Apr 30 '23 11:04 micke

Closing as i can't replicate the issue

micke avatar Aug 10 '24 20:08 micke