1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/app/models/action_mailbox/inbound_email.rb
David Heinemeier Hansson 8a0a103495 ActionMailroom -> ActionMailbox
We didn't end up using the mailroom metaphor directly, so let's stick with a more conventional naming strategy.
2018-09-28 12:19:43 -07:00

22 lines
499 B
Ruby

require "mail"
class ActionMailbox::InboundEmail < ActiveRecord::Base
self.table_name = "action_mailbox_inbound_emails"
include Incineratable, MessageId, Routable
has_one_attached :raw_email
enum status: %i[ pending processing delivered failed bounced ]
def self.mail_from_source(source)
Mail.new Mail::Utilities.binary_unsafe_to_crlf(source.to_s)
end
def mail
@mail ||= self.class.mail_from_source(source)
end
def source
@source ||= raw_email.download
end
end