MailCollector
API reference › Debug › collectors › MailCollector
Captures every mail message dispatched during the request for the Mail panel.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$mailPath | string | Filesystem path (Yii alias) where every captured message is persisted as a .eml file. Default: '@runtime/debug/mail'. | MailCollector |
$module | yii\| | Debug module supplying the log target and sibling collectors, assigned by the module on registration. Default: null. | Collector |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
capture() final | Encodes the typed snapshot built by the subclass into the payload persisted for the panel. | Collector |
getMessagesFileName() | Returns the file names of the captured .eml files persisted under $mailPath. | MailCollector |
id() | Returns the stable ID pairing this collector with the Mail panel. | MailCollector |
instrument() | Installs low-level instrumentation as soon as the module registers the collector, before the panels are built. | Collector |
reconcileFiles() | Retries cleanup of aged .eml files no longer referenced by a retained snapshot. | MailCollector |
removeFiles() | Removes safe captured files associated with snapshots that were not committed or have been evicted. | MailCollector |
shutdown() final | Deactivates the collector once, releasing any subscription created by start(). | Collector |
startup() final | Activates the collector once at the start of the request lifecycle. | Collector |
getLogMessages() protected | Returns the accumulated log messages, optionally filtered by level, category, and exclusion lists. | Collector |
getLogTarget() protected | Returns the initialized log target of the owning debug module. | Collector |
isStarted() protected | Returns whether the collector is active for the current request. | Collector |
snapshot() protected | Snapshots the captured messages, with their metadata (time, reply, bcc, cc, from, to, subject, headers, etc.). | MailCollector |
start() protected | Registers the mailer listener that persists each dispatched message and records its metadata. | MailCollector |
stop() protected | Detaches the mailer listener and clears the captured messages, so a reused worker process starts clean. | MailCollector |
Method details
Section titled “Method details”getMessagesFileName()
Section titled “getMessagesFileName() ”public function getMessagesFileName(): array<int, string>Returns the file names of the captured .eml files persisted under $mailPath.
Returns
array<int, string>: File names in send order.
public function id(): stringReturns the stable ID pairing this collector with the Mail panel.
Returns
string: Stable collector ID.
reconcileFiles()
Section titled “reconcileFiles() ”public function reconcileFiles(iterable<string> $referencedFiles): voidRetries cleanup of aged .eml files no longer referenced by a retained snapshot.
The grace period prevents a concurrent request’s new mail from being deleted before its snapshot commits.
Parameters
| Parameter | Type | Description |
|---|---|---|
$referencedFiles | iterable<string> | File names referenced by the current manifest. |
removeFiles()
Section titled “removeFiles() ”public function removeFiles(iterable<string> $files): voidRemoves safe captured files associated with snapshots that were not committed or have been evicted.
Parameters
| Parameter | Type | Description |
|---|---|---|
$files | iterable<string> | Captured file names. |
snapshot()
Section titled “snapshot() ”protected function snapshot(): PHPForge\Debug\Panel\Mail\MailSnapshot|nullSnapshots the captured messages, with their metadata (time, reply, bcc, cc, from, to, subject, headers, etc.).
Returns
PHPForge\Debug\Panel\Mail\MailSnapshot|null: Captured mail payload; null when the collector never started.
start()
Section titled “start() ”protected function start(): voidRegisters the mailer listener that persists each dispatched message and records its metadata.
stop()
Section titled “stop() ”protected function stop(): voidDetaches the mailer listener and clears the captured messages, so a reused worker process starts clean.