Class: Reportme::Mailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
lib/reportme/mailer.rb

Instance Method Summary collapse

Instance Method Details

#message(_from, _recipients, _subject, _body, attachments = []) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/reportme/mailer.rb', line 3

def message (_from, _recipients, _subject, _body, attachments=[])
  
  subject(_subject)
  from(_from)
  recipients(_recipients)
  body(_body)
  
  unless attachments.blank?
    attachments.each do |att|
      content_type = att[:content_type] 

      attachment content_type do |a|
        a.filename = att[:filename]
      
        a.body = File.read(att[:filepath])  if att[:filepath]
        a.body = att[:text]                 if att[:text]
      
        a.transfer_encoding = 'quoted-printable' if content_type =~ /^text\//
      end
    end
  end

end