Class: ActionMailbox::InboundEmail

Inherits:
ActiveRecord::Base show all
Includes:
Incineratable, MessageId, Routable
Defined in:
actionmailbox/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

Constant Summary

Constants included from ActiveRecord::Querying

ActiveRecord::Querying::QUERYING_METHODS

Constants included from ActiveRecord::ConnectionHandling

ActiveRecord::ConnectionHandling::DEFAULT_ENV, ActiveRecord::ConnectionHandling::ER_BAD_DB_ERROR, ActiveRecord::ConnectionHandling::RAILS_ENV

Constants included from ActiveRecord::SecureToken

ActiveRecord::SecureToken::MINIMUM_TOKEN_LENGTH

Constants included from ActiveRecord::Transactions

ActiveRecord::Transactions::ACTIONS

Constants included from ActiveModel::SecurePassword

ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED

Constants included from ActiveRecord::Callbacks

ActiveRecord::Callbacks::CALLBACKS

Constants included from ActiveRecord::AttributeMethods

ActiveRecord::AttributeMethods::RESTRICTED_CLASS_METHODS

Constants included from ActiveModel::AttributeMethods

ActiveModel::AttributeMethods::CALL_COMPILABLE_REGEXP, ActiveModel::AttributeMethods::NAME_COMPILABLE_REGEXP

Instance Attribute Summary

Attributes included from ActiveRecord::ConnectionHandling

#connection_specification_name

Instance Method Summary collapse

Methods included from Incineratable

#incinerate, #incinerate_later

Methods included from ActiveSupport::Concern

#append_features, #class_methods, extended, #included, #prepend_features, #prepended

Methods included from Routable

#route, #route_later

Methods included from ActiveRecord::Aggregations::ClassMethods

#composed_of

Methods included from ActiveRecord::Delegation::DelegateCache

#generate_relation_method, #inherited, #initialize_relation_delegate_cache, #relation_delegate_class

Methods included from ActiveRecord::Enum

#enum, extended, #inherited

Methods included from ActiveRecord::Explain

#collecting_queries_for_explain, #exec_explain

Methods included from ActiveRecord::Translation

#i18n_scope, #lookup_ancestors

Methods included from ActiveModel::Translation

#human_attribute_name, #i18n_scope, #lookup_ancestors

Methods included from ActiveModel::Naming

extended, #model_name, param_key, plural, route_key, singular, singular_route_key, uncountable?

Methods included from ActiveRecord::Querying

#count_by_sql, #find_by_sql

Methods included from ActiveRecord::QueryCache::ClassMethods

#cache, #uncached

Methods included from ActiveRecord::ConnectionHandling

#clear_cache!, #clear_query_caches_for_current_thread, #connected?, #connected_to, #connected_to?, #connection, #connection_config, #connection_db_config, #connection_pool, #connects_to, #current_role, #establish_connection, #lookup_connection_handler, #mysql2_connection, #postgresql_connection, #primary_class?, #remove_connection, #retrieve_connection, #sqlite3_connection

Methods included from ActiveSupport::DescendantsTracker

clear, #descendants, descendants, #direct_descendants, direct_descendants, #inherited, store_inherited

Methods included from ActiveSupport::Benchmarkable

#benchmark

Methods included from ActiveRecord::Suppressor

#save, #save!

Methods included from ActiveRecord::Serialization

#serializable_hash

Methods included from ActiveModel::Serializers::JSON

#as_json, #from_json

Methods included from ActiveModel::Serialization

#serializable_hash

Methods included from ActiveRecord::Reflection

add_aggregate_reflection, add_reflection, create

Methods included from ActiveRecord::NoTouching

applied_to?, apply_to, #no_touching?, #touch, #touch_later

Methods included from ActiveRecord::TouchLater

#touch, #touch_later

Methods included from ActiveRecord::Transactions

#before_committed!, #committed!, #destroy, #rolledback!, #save, #save!, #touch, #transaction, #trigger_transactional_callbacks?, #with_transaction_returning_status

Methods included from ActiveRecord::NestedAttributes

#_destroy

Methods included from ActiveRecord::AutosaveAssociation

#changed_for_autosave?, #destroyed_by_association, #destroyed_by_association=, #mark_for_destruction, #marked_for_destruction?, #reload

Methods included from ActiveRecord::Associations

#association, #association_cached?, eager_load!, #initialize_dup, #reload

Methods included from ActiveSupport::Autoload

#autoload, #autoload_at, #autoload_under, #autoloads, #eager_autoload, #eager_load!, extended

Methods included from ActiveRecord::Timestamp

#initialize_dup

Methods included from ActiveRecord::Callbacks

#destroy, #increment!, #touch

Methods included from ActiveRecord::AttributeMethods

#[], #[]=, #accessed_fields, #attribute_for_inspect, #attribute_names, #attribute_present?, #attributes, #has_attribute?, #respond_to?

Methods included from ActiveModel::AttributeMethods

#attribute_missing, #method_missing, #respond_to?, #respond_to_without_attributes?

Methods included from ActiveRecord::Locking::Pessimistic

#lock!, #with_lock

Methods included from ActiveRecord::Locking::Optimistic

#locking_enabled?

Methods included from ActiveRecord::Validations

#save, #save!, #valid?

Methods included from ActiveModel::Validations

#errors, #initialize_dup, #invalid?, #valid?, #validate!, #validates_with

Methods included from ActiveRecord::Integration

#cache_key, #cache_key_with_version, #cache_version, #to_param

Methods included from ActiveModel::Conversion

#to_key, #to_model, #to_param, #to_partial_path

Methods included from ActiveModel::AttributeAssignment

#assign_attributes

Methods included from ActiveRecord::Scoping

#initialize_internals_callback, #populate_with_current_scope_attributes

Methods included from ActiveRecord::Inheritance

#initialize_dup

Methods included from ActiveRecord::ModelSchema

derive_join_table_name

Methods included from ActiveRecord::Persistence

#becomes, #becomes!, #decrement, #decrement!, #delete, #destroy, #destroy!, #destroyed?, #increment, #increment!, #new_record?, #persisted?, #previously_new_record?, #reload, #save, #save!, #toggle, #toggle!, #touch, #update, #update!, #update_attribute, #update_column, #update_columns

Methods included from ActiveRecord::Core

#<=>, #==, #blank?, #connection_handler, #encode_with, #freeze, #frozen?, #hash, #init_with, #init_with_attributes, #initialize, #initialize_dup, #inspect, #present?, #pretty_print, #readonly!, #readonly?, #slice, #strict_loading!, #strict_loading?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveModel::AttributeMethods

Instance Method Details

#mailObject


35
36
37
# File 'actionmailbox/app/models/action_mailbox/inbound_email.rb', line 35

def mail
  @mail ||= Mail.from_source(source)
end

#processed?Boolean


43
44
45
# File 'actionmailbox/app/models/action_mailbox/inbound_email.rb', line 43

def processed?
  delivered? || failed? || bounced?
end

#sourceObject


39
40
41
# File 'actionmailbox/app/models/action_mailbox/inbound_email.rb', line 39

def source
  @source ||= raw_email.download
end