mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
8a0a103495
We didn't end up using the mailroom metaphor directly, so let's stick with a more conventional naming strategy.
22 lines
499 B
Ruby
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
|