Class: ReaderNotifier

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/models/reader_notifier.rb

Instance Method Summary collapse

Instance Method Details

#message(reader, message, sender = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/reader_notifier.rb', line 5

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.host'] || 'www.example.com'
  default_url_options[:host] = host
  sender = Radiant::Config['email.name'] ||  message.created_by.name
  sender_address = Radiant::Config['email.address'] || message.created_by.email

  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,
    :group => message.group,
    :sender => sender,
    :reply_to => sender_address,
    :reader => reader,
    :site => site || {
      :name => Radiant::Config['site.name'],
      :url => Radiant::Config['site.host']
    }
  })
end