Sha256: 60af729d83c0996c9eb85f330e5d614938ee772cfa7d069e1a3c265ed9aced4d

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 KB

Contents

class ReaderNotifier < ActionMailer::Base

  # this sets a default that will be overridden by the layout association of each message as it is sent out
  radiant_layout lambda { Radiant::Config['email.layout'] || 'email'}
  
  def message(reader, message, sender=nil)
    site = reader.site if reader.respond_to?(:site)
    prefix = site ? site.abbreviation : Radiant::Config['email.prefix']
    host = site ? site.base_domain : Radiant::Config['site.domain'] || 'www.example.com'
    default_url_options[:host] = host
    sender = Radiant::Config['email.name'] || "sender_not_configured"
    sender_address = Radiant::Config['email.address'] || "admin@#{host}"

    message_layout(message.layout) if message.layout
    content_type("text/html")
    subject (prefix || '') + message.subject
    recipients(reader.email)
    from ["#{sender} <#{sender_address}>"]
    reply_to = [sender_address]
    subject message.subject
    sent_on(Time.now)

    body({
      :host => host,
      :title => message.subject,
      :message => message.filtered_body,
      :sender => sender,
      :reply_to => sender_address,
      :reader => reader,
      :site => site || {
        :name => Radiant::Config['site.title'],
        :url => Radiant::Config['site.domain']
      }
    })
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
radiant-reader-extension-1.2.4 app/models/reader_notifier.rb
radiant-reader-extension-1.2.3 app/models/reader_notifier.rb
radiant-reader-extension-1.2.2 app/models/reader_notifier.rb
radiant-reader-extension-1.2.1 app/models/reader_notifier.rb
radiant-reader-extension-1.2.0 app/models/reader_notifier.rb
radiant-reader-extension-1.1.1 app/models/reader_notifier.rb
radiant-reader-extension-1.1.0 app/models/reader_notifier.rb
radiant-reader-extension-1.0.1 app/models/reader_notifier.rb
radiant-reader-extension-1.0.0 app/models/reader_notifier.rb