Do you have this user registered at your site with an email address? There is no way to "test" a existing email with ex. google or other email hosts. (The smtp protocol allows for this but its a spam trap to have this available... )
You do have the ability to test if the domain exists and is a valid domain.. But again this can't be 100% because not all servers allow this inquiry and your connection to them might timeout This would validate the domain (but could fail if you timeout.. ): require 'resolv' def validate unless errors.on(:email) unless valid_domain?(email) logger.debug "[DEBUG] - Domain name #{email} has a problem." errors.add(:email, 'domain name appers to be incorrect') end end end def valid_domain?(email) domain = email.match(EMAIL_PATTERN)[2] dns = Resolv::DNS.new Timeout::timeout(SERVER_TIMEOUT) do # Check the MX record mx_records = dns.getresources(domain, Resolv::DNS::Resource::IN::MX) mx_records.sort_by {|mx| mx.preference}.each do |mx| a_records = dns.getresources(mx.exchange.to_s, Resolv::DNS::Resource::IN::A) return true if a_records.any? end #Try a straight A record a_records = dns.getresources(domain, Resolv::DNS::Resource::IN::A) a_records.any? end rescue Timeout::Error, Errno::ECONNREFUSED false end Using a pattern is faster and just plain easier... EMAIL_PATTERN = /\A([EMAIL PROTECTED])@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i validates_format_of :email, :with => EMAIL_PATTERN --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---