Class: ActionMailbox::InboundEmail
- Includes:
- Incineratable, MessageId, Routable
- Defined in:
- app/models/action_mailbox/inbound_email.rb
Overview
The InboundEmail
is an Active Record that keeps a reference to the raw email stored in Active Storage and tracks the status of processing. By default, incoming emails will go through the following lifecycle:
-
Pending: Just received by one of the ingress controllers and scheduled for routing.
-
Processing: During active processing, while a specific mailbox is running its #process method.
-
Delivered: Successfully processed by the specific mailbox.
-
Failed: An exception was raised during the specific mailbox’s execution of the
#process
method. -
Bounced: Rejected processing by the specific mailbox and bounced to sender.
Once the InboundEmail
has reached the status of being either delivered
, failed
, or bounced
, it’ll count as having been #processed?
. Once processed, the InboundEmail
will be scheduled for automatic incineration at a later point.
When working with an InboundEmail
, you’ll usually interact with the parsed version of the source, which is available as a Mail
object from #mail
. But you can also access the raw source directly using the #source
method.
Examples:
inbound_email.mail.from # => '[email protected]'
inbound_email.source # Returns the full rfc822 source of the email as text
Defined Under Namespace
Modules: Incineratable, MessageId, Routable
Instance Method Summary collapse
Methods included from Incineratable
#incinerate, #incinerate_later
Methods included from Routable
Instance Method Details
#instrumentation_payload ⇒ Object
:nodoc:
45 46 47 48 49 50 51 |
# File 'app/models/action_mailbox/inbound_email.rb', line 45 def instrumentation_payload # :nodoc: { id: id, message_id: , status: status } end |
#mail ⇒ Object
33 34 35 |
# File 'app/models/action_mailbox/inbound_email.rb', line 33 def mail @mail ||= Mail.from_source(source) end |
#processed? ⇒ Boolean
41 42 43 |
# File 'app/models/action_mailbox/inbound_email.rb', line 41 def processed? delivered? || failed? || bounced? end |
#source ⇒ Object
37 38 39 |
# File 'app/models/action_mailbox/inbound_email.rb', line 37 def source @source ||= raw_email.download end |