lib/messenger/email.rb in messenger-0.1.1 vs lib/messenger/email.rb in messenger-0.2.0

- old
+ new

@@ -3,11 +3,11 @@ module Messenger class Email def self.valid_url?(url) - !!url.match(/mailto:[^@]+@.*/) + !!url.match(/^(mailto:)?[^@]+@.*$/) end # URL format: # mailto:email@example.com # @@ -22,9 +22,11 @@ subject options[:email_subject] body message end mail.deliver! Result.new(true, nil) + rescue Errno::ECONNREFUSED, Errno::EAFNOSUPPORT => e + Result.new(false, e) end def self.obfuscate(url) raise URLError, "The URL provided is invalid" unless valid_url?(url) url