Skip to content

Instantly share code, notes, and snippets.

@jasondew
Created June 24, 2010 00:11
Show Gist options
  • Save jasondew/450774 to your computer and use it in GitHub Desktop.
Save jasondew/450774 to your computer and use it in GitHub Desktop.
class Courier < ActionMailer::Base
CIPHER = ActiveSupport::MessageEncryptor.new("redacted", "aes-256-cbc")
module ClassMethods
delegate :encrypt, :to => :"Courier::CIPHER"
def valid_email_address? email_address
(not email_address.blank?) and email_address.include?("@")
end
def decrypt cipher
begin
Courier::CIPHER.decrypt(cipher)
rescue ActiveSupport::MessageEncryptor::InvalidMessage
nil
end
end
end
extend ClassMethods
def email to_address, from_text, message
recipients to_address
from "[email protected]"
subject "Message from the website"
body :from_text => from_text, :message => message
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment