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 "do-not-reply@website.org" | |
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