InboundEmail 是一个 Active Record,它保留对存储在 Active Storage 中的原始邮件的引用,并跟踪处理状态。默认情况下,传入邮件将经历以下生命周期:
-
待处理:刚刚通过某个入口控制器接收并安排路由。
-
处理中:在主动处理期间,当某个特定的邮箱正在运行其 `process` 方法。
-
已送达:由特定的邮箱成功处理。
-
失败:在特定的邮箱执行 `process` 方法期间引发了异常。
-
已退回:被特定的邮箱拒绝处理并退回给发件人。
一旦 InboundEmail 达到 delivered、failed 或 bounced 状态,它将被视为已processed?。一旦处理完毕,InboundEmail 将被安排在稍后自动销毁。
在使用 InboundEmail 时,您通常会与源的解析版本进行交互,该版本可通过 `mail` 方法作为 Mail 对象获得。但您也可以使用 `source` 方法直接访问原始源。
示例
inbound_email.mail.from # => 'david@loudthinking.com' inbound_email.source # Returns the full rfc822 source of the email as text
命名空间
- 模块 ActionMailbox::InboundEmail::Incineratable
- 模块 ActionMailbox::InboundEmail::MessageId
- 模块 ActionMailbox::InboundEmail::Routable
方法
- M
- P
- S
实例公共方法
mail() 链接
Source: 显示 | 在 GitHub 上
# File actionmailbox/app/models/action_mailbox/inbound_email.rb, line 33 def mail @mail ||= Mail.from_source(source) end
processed?() 链接
Source: 显示 | 在 GitHub 上
# File actionmailbox/app/models/action_mailbox/inbound_email.rb, line 41 def processed? delivered? || failed? || bounced? end
source() 链接
Source: 显示 | 在 GitHub 上
# File actionmailbox/app/models/action_mailbox/inbound_email.rb, line 37 def source @source ||= raw_email.download end