lib/messenger/email.rb in messenger-0.5.0 vs lib/messenger/email.rb in messenger-0.6.0
- old
+ new
@@ -1,11 +1,11 @@
require 'mail'
class Messenger::Email
def self.valid_url?(url)
- !!url.match(/^(mailto:)?[^@]+@.*$/)
+ !!url.match(/\A(mailto:)?[^@]+@.*\Z/)
end
# URL format:
# mailto:email@example.com
#
@@ -14,10 +14,10 @@
# :email_subject => The subject of the email
def self.deliver(url, message, options={})
raise Messenger::URLError, "The URL provided is invalid" unless valid_url?(url)
mail = Mail.new do
from options[:email_from]
- to url.sub(/mailto:/, '')
+ to url.sub(/\Amailto:/, '')
subject options[:email_subject]
body message
end
mail.deliver!
Messenger::Result.new(true, nil)