Sha256: 2a9b41ac40cf141a330501a488cc8606108bd92e22af92dc448dc8da9b601716

Contents?: true

Size: 914 Bytes

Versions: 3

Compression:

Stored size: 914 Bytes

Contents

module NotifyOn
  class NotificationMailer < ApplicationMailer

    helper 'notify_on/mailer'

    def notify(notification_id, template = 'notify', files = [])
      @notification = NotifyOn::Notification.find_by_id(notification_id)
      @recipient = @notification.recipient
      @sender = @notification.sender
      @trigger = @notification.trigger
      # Add attachments.
      files.each { |attr| attachments[attr[:name]] = attr[:file] }
      # Save a reference to the message if requested.
      if @notification.should_save_email_id?
        headers['message-id'] = (message_id = SecureRandom.uuid)
        @trigger.update_columns(:message_id => message_id)
      end
      mail :to => @recipient.email,
           :from => @notification.email_from,
           :subject => @notification.email_subject,
           :template_path => 'notifications',
           :template_name => template
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
notify_on-1.0.3 app/mailers/notify_on/notification_mailer.rb
notify_on-1.0.2 app/mailers/notify_on/notification_mailer.rb
notify_on-1.0.1 app/mailers/notify_on/notification_mailer.rb