Module: ActionMailbox::InboundEmail::MessageId::ClassMethods

Defined in:
app/models/action_mailbox/inbound_email/message_id.rb

Instance Method Summary collapse

Instance Method Details

#create_and_extract_message_id!(source, **options) ⇒ Object

Create a new ‘InboundEmail` from the raw `source` of the email, which be uploaded as a Active Storage attachment called `raw_email`. Before the upload, extract the Message-ID from the `source` and set it as an attribute on the new `InboundEmail`.



18
19
20
21
22
# File 'app/models/action_mailbox/inbound_email/message_id.rb', line 18

def create_and_extract_message_id!(source, **options)
  create! message_id: extract_message_id(source), **options do |inbound_email|
    inbound_email.raw_email.attach io: StringIO.new(source), filename: "message.eml", content_type: "message/rfc822"
  end
end