Sha256: d144beab377b3a36e24ea6364499ef37f95d596410acd7274637e877f708f4d7

Contents?: true

Size: 814 Bytes

Versions: 1

Compression:

Stored size: 814 Bytes

Contents

module Emilio
  class Receiver < ActionMailer::Base
    def receive(email)
      @email = email
      @html = false
      @attachments = email.attachments
      @sender = email.from.to_s

      if email.multipart?
        if email.html_part.present?
          ic = Iconv.new('utf-8', email.html_part.charset)
          @body = ic.iconv(email.html_part.body.to_s)
          @html = true
        else
          ic = Iconv.new('utf-8', email.text_part.charset)
          @body = ic.iconv(email.text_part.body.to_s)
        end
      else
        ic = Iconv.new('utf-8', email.charset)
        @body = ic.iconv(email.body.to_s)
      end
      @subject = ic.iconv(email.subject)
      Emilio.logger.info("Parsed email [#{@subject}] from [#{@sender}]")

      parse
    end

  protected
    def parse
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emilio-0.1.0 lib/emilio/receiver.rb