Skip to content
Corex

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.

__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)”

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.

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.

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.