Sha256: 2ee5879d9b34b9b143ea8582becc083818c9b3a40f211c64ad1c90ff4e7259f3
Contents?: true
Size: 1.18 KB
Versions: 5
Compression:
Stored size: 1.18 KB
Contents
module ActiveWrapper class Mail attr_reader :base, :env, :config def initialize(options) @base = options[:base] @config = { :smtp => options[:smtp] || {}, :imap => options[:imap] || {} } @env = options[:env].to_s path = "#{base}/config/mail.yml" if @env == 'test' ActionMailer::Base.delivery_method = :test @config = nil else if File.exists?(path) yaml = YAML::load(File.open(path)) if yaml && yaml = yaml[@env].to_options @config[:imap] = yaml[:imap].to_options unless @config[:imap] @config[:smtp] = yaml[:smtp].to_options unless @config[:smtp] end end if @config[:smtp] ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = @config[:smtp] end end end def deliver(options) Mailer.deliver_email(options) end class Mailer < ActionMailer::Base def email(options) from options[:from] recipients options[:to] subject options[:subject] body options[:body] end end end end
Version data entries
5 entries across 5 versions & 2 rubygems