Class: Emilio::Receiver

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
lib/emilio/receiver.rb

Instance Method Summary collapse

Instance Method Details

#receive(email) ⇒ 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/emilio/receiver.rb', line 3

def receive(email)
  @email = email
  @html = false
  @attachments = email.attachments
  @sender = email.from.to_s

  @body = if email.multipart?
    if email.html_part.present?
      @html = true
      email.html_part
    else
      email.text_part
    end
  else
    ic = Iconv.new('utf-8', email.charset)
    email
  end.body.to_s.encode("utf-8")

  @subject = email.subject.encode
  Emilio.logger.info("Parsed email [#{@subject}] from [#{@sender}]")

  parse
end