]> git.openstreetmap.org Git - rails.git/blob - app/controllers/concerns/email_methods.rb
Show fork icons for GraphHopper keep right/left instructions
[rails.git] / app / controllers / concerns / email_methods.rb
1 module EmailMethods
2   extend ActiveSupport::Concern
3
4   private
5
6   def canonical_email(email)
7     local_part, domain = email.split("@")
8
9     local_part.sub!(/\+.*$/, "")
10
11     local_part.delete!(".") if %w[gmail.com googlemail.com].include?(domain)
12
13     "#{local_part}@#{domain}"
14   end
15
16   ##
17   # get list of MX servers for a domains
18   def domain_mx_servers(domain)
19     Resolv::DNS.open do |dns|
20       dns.getresources(domain, Resolv::DNS::Resource::IN::MX).collect { |mx| mx.exchange.to_s }
21     end
22   end
23 end