Rails regex with include
I'm finding MX records based on a user's email to determine if they use
gmail. The mx server records come back like this:
ASPMX.L.GOOGLE.com
ALT1.ASPMX.L.GOOGLE.com
ALT2.ASPMX.L.GOOGLE.com
ASPMX2.GOOGLEMAIL.com
ASPMX3.GOOGLEMAIL.com
alt4.gmail-smtp-in.l.google.com
alt3.gmail-smtp-in.l.google.com
alt2.gmail-smtp-in.l.google.com
gmail-smtp-in.l.google.com
alt1.gmail-smtp-in.l.google.com
Where non google mail servers send back stuff like:
mx2.emailsrvr.com
mx1.emailsrvr.com
nil
What is a good way to determine if one of the mx records contain a google
mx record. I've been trying:
if mx.any? {|server| server.exchange.to_s.include? "google"} then
return true
end
This doesn't work as it requires an exactly match. Any elegant ideas? Thanks
No comments:
Post a Comment