Class: Protege::Gateway::Mail::Outbound
- Inherits:
-
Object
- Object
- Protege::Gateway::Mail::Outbound
- Defined in:
- lib/protege/gateway/mail/outbound.rb
Overview
Builder for outbound ::Mail::Message objects — the one place the engine assembles mail it
sends, whether a brand-new console conversation or a threaded reply.
Centralizing construction keeps the conventions (a synthetic angle-bracketed Message-ID, a
UTF-8 plain-text body, a Date stamp) and the threading-header normalization (+In-Reply-To+ via
MessageId, References via References) in a single tested spot, rather than duplicated
across RepliesController, ThreadsController, and host tools like SendEmailTool.
Class Method Summary collapse
-
.build(from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: []) ⇒ ::Mail::Message
Build and return a ready-to-deliver
::Mail::Message.
Instance Method Summary collapse
-
#initialize(from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: []) ⇒ Outbound
constructor
Store the envelope and threading inputs.
-
#message ⇒ ::Mail::Message
Assemble the
::Mail::Messagefrom the stored inputs.
Constructor Details
#initialize(from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: []) ⇒ Outbound
Store the envelope and threading inputs. Prefer the .build factory.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/protege/gateway/mail/outbound.rb', line 69 def initialize( from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: [] ) @from = from @to = to @subject = subject @body = body @cc = cc @bcc = bcc @in_reply_to = in_reply_to @references = references @attachments = end |
Class Method Details
.build(from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: []) ⇒ ::Mail::Message
Build and return a ready-to-deliver ::Mail::Message.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/protege/gateway/mail/outbound.rb', line 41 def build( from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: [] ) new( from:, to:, subject:, body:, cc:, bcc:, in_reply_to:, references:, attachments: ). end |
Instance Method Details
#message ⇒ ::Mail::Message
Assemble the ::Mail::Message from the stored inputs.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/protege/gateway/mail/outbound.rb', line 94 def ::Mail.new.tap do |m| m.from = @from m.to = @to m.cc = @cc m.bcc = @bcc m.subject = @subject m. = MessageId.synthetic(domain: sender_domain).value m.date = Time.current m.in_reply_to = parent_id if parent_id m.references = reference_values if reference_values.any? assign_content(m) end end |