Class: Resend::ActionMailbox::MessageBuilder
- Inherits:
-
Object
- Object
- Resend::ActionMailbox::MessageBuilder
- Defined in:
- lib/resend/action_mailbox/message_builder.rb
Overview
Rebuilds the full RFC 822 source of a received email so it can be ingested by Action Mailbox.
Resend's email.received webhook only carries metadata, so the message is
fetched from the Received Emails API. When the API exposes a raw message
download it is used as-is; otherwise the message is reconstructed as a
Mail::Message from its parts, downloading each attachment through the
attachments API.
Constant Summary collapse
- STRUCTURAL_HEADERS =
Headers that describe the reconstructed MIME structure and therefore cannot be copied verbatim from the original message.
%w[content-type content-transfer-encoding mime-version].freeze
- ENVELOPE_FIELDS =
Envelope fields that are set from the API response when the original header of the same name is not available.
%i[from to cc bcc reply_to subject message_id].freeze
Instance Method Summary collapse
-
#initialize(email_id) ⇒ MessageBuilder
constructor
A new instance of MessageBuilder.
-
#raw_email ⇒ String
The full RFC 822 source of the received email.
Constructor Details
#initialize(email_id) ⇒ MessageBuilder
Returns a new instance of MessageBuilder.
25 26 27 |
# File 'lib/resend/action_mailbox/message_builder.rb', line 25 def initialize(email_id) @email_id = email_id end |
Instance Method Details
#raw_email ⇒ String
Returns the full RFC 822 source of the received email.
30 31 32 |
# File 'lib/resend/action_mailbox/message_builder.rb', line 30 def raw_email raw_download || .to_s end |