Sha256: 6eb8aac165e21f81794afa9517f823d699cc5b962d054fde73f4b76c9189319b
Contents?: true
Size: 786 Bytes
Versions: 1
Compression:
Stored size: 786 Bytes
Contents
require 'mail' module Messenger class 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.send(url, message, options={}) raise 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! Result.new(true, nil) end def self.obfuscate(url) raise URLError, "The URL provided is invalid" unless valid_url?(url) url end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
messenger-0.1.1 | lib/messenger/email.rb |