MessageBuilder
Corex\Email\Message\MessageBuilder · class · Add-ons layer
The fluent API behind the Mail facade. Collects recipients (fixed/role/dynamic) and either a template + context or an ad-hoc subject + body, then build()s an immutable EmailMessage — resolving recipients through the RecipientResolver and rendering the template through the renderer. send() hands the message to the MailService. build() is pure and independently testable.
Public API
Section titled “Public API”__construct(string|array $to, TemplateRegistry $templates, TemplateRenderer $renderer, RecipientResolver $resolver, MailService $service)
Section titled “__construct(string|array $to, TemplateRegistry $templates, TemplateRenderer $renderer, RecipientResolver $resolver, MailService $service)”toRole(string $role): self
Section titled “toRole(string $role): self”toDynamic(string $contextPath): self
Section titled “toDynamic(string $contextPath): self”cc(string|array $cc): self
Section titled “cc(string|array $cc): self”bcc(string|array $bcc): self
Section titled “bcc(string|array $bcc): self”from(string $address): self
Section titled “from(string $address): self”Send this message from a specific mailbox rather than the configured default (#150). The address only — the display name stays configured, because the name is the brand and does not change with the mailbox.
attachMedia(int $attachmentId): self
Section titled “attachMedia(int $attachmentId): self”Attach a file from the media library by id (spec 081). Named attachMedia() because ../../../../docs/internal/COREX-EMAIL-ADDON.md has documented that name since the add-on was specified. attach() and attachGenerated() are documented too and are deliberately absent: attach() implied a path, and a framework-generated file has no id until something stores it — at which point this method is what you want.
replyTo(string $address): self
Section titled “replyTo(string $address): self”subject(string $subject): self
Section titled “subject(string $subject): self”body(string $html): self
Section titled “body(string $html): self”template(string $name): self
Section titled “template(string $name): self”with(array $context): self
Section titled “with(array $context): self”sentUnder(string $messageId): self
Section titled “sentUnder(string $messageId): self”The id this email is sent under, so that a later one can say it answers it (spec 106, FR-042). Anything that is not an id is passed over.