Module: Tolliver::Mailers::NotificationMailer

Extended by:
ActiveSupport::Concern
Included in:
NotificationMailer
Defined in:
lib/tolliver/mailers/notification_mailer.rb

Instance Method Summary collapse

Instance Method Details

#notify(notification, notification_receiver) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tolliver/mailers/notification_mailer.rb', line 17

def notify(notification, notification_receiver)

  # Sender
  @sender_email = Tolliver.email_sender
  raise Tolliver::Errors::StandardError.new("Please specify e-mail sender.") if @sender_email.nil?
  unless Tolliver.email_sender_name.blank?
    @sender_email = "#{Tolliver.email_sender_name} <#{@sender_email}>"
  end

  # Other view data
  @notification = notification
  @notification_receiver = notification_receiver

  # Attachments
  notification.notification_attachments.each do |notification_attachment|
    attachments[notification_attachment.name] = notification_attachment.read if notification_attachment.read
  end

  # Mail
  mail(from: @sender_email, to: @notification_receiver.receiver_email.to_s, subject: @notification.subject)
end