Created
June 24, 2010 00:11
-
-
Save jasondew/450774 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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