Sha256: 7cc9c8a238358da0e4ee3126ecb8caa5da3be9e1a940544a03ecf236c8b5bc63
Contents?: true
Size: 854 Bytes
Versions: 12
Compression:
Stored size: 854 Bytes
Contents
require 'mail' class Messenger::Email def self.valid_url?(url) !!url.match(/^(mailto:)?[^@]+@.*$/) end # URL format: # mailto:email@example.com # # Options: # :email_from => Who the email is from # :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:/, '') subject options[:email_subject] body message end mail.deliver! Messenger::Result.new(true, nil) rescue Errno::ECONNREFUSED, Errno::EAFNOSUPPORT => e Messenger::Result.new(false, e) end def self.obfuscate(url) raise Messenger::URLError, "The URL provided is invalid" unless valid_url?(url) url end end
Version data entries
12 entries across 12 versions & 1 rubygems