Sha256: f983a82a98c0667bed7ab9c76b95b572771366e11c558a05159caf6366977738
Contents?: true
Size: 858 Bytes
Versions: 3
Compression:
Stored size: 858 Bytes
Contents
require 'mail' class Messenger::Email def self.valid_url?(url) !!url.match(/\A(mailto:)?[^@]+@.*\Z/) 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(/\Amailto:/, '') 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
messenger-0.7.1 | lib/messenger/email.rb |
messenger-0.7.0 | lib/messenger/email.rb |
messenger-0.6.0 | lib/messenger/email.rb |