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_mailroom/inbound_email.rb

23 lines
501 B
Ruby
Raw Normal View History

2018-09-18 01:15:27 -04:00
require "mail"
2018-09-17 19:56:55 -04:00
class ActionMailroom::InboundEmail < ActiveRecord::Base
2018-09-17 20:15:53 -04:00
self.table_name = "action_mailroom_inbound_emails"
2018-09-17 19:55:07 -04:00
2018-09-28 14:01:49 -04:00
include Incineratable, MessageId, Routable
2018-09-17 19:55:07 -04:00
2018-09-19 19:40:56 -04:00
has_one_attached :raw_email
2018-09-17 19:55:07 -04:00
enum status: %i[ pending processing delivered failed bounced ]
2018-09-28 14:01:49 -04:00
def self.mail_from_source(source)
Mail.new Mail::Utilities.binary_unsafe_to_crlf(source.to_s)
end
2018-09-17 19:55:07 -04:00
def mail
@mail ||= self.class.mail_from_source(source)
end
def source
@source ||= raw_email.download
2018-09-17 19:55:07 -04:00
end
end