cirandas.net

ref: master

plugins/newsletter/lib/newsletter_plugin/newsletter_mailing.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class NewsletterPlugin::NewsletterMailing < EnvironmentMailing

  attr_accessible :source, :person, :locale

  validates_presence_of :person

  def url
    "#{self.source.top_url}/plugin/newsletter/mailing/#{self.id}"
  end

  def source
    NewsletterPlugin::Newsletter.find(source_id)
  end

  def deliver
    source.additional_recipients.each do |recipient|
      begin
        Mailing::Sender.notification(self, recipient[:email]).deliver
      rescue Exception => ex
        Rails.logger.error("#{ex.class.to_s} - #{ex.to_s} at #{__FILE__}:#{__LINE__}")
      end
    end
    super
  end

end