Skip to content
PHP Ecosystem
Explore

MailFileStore

API reference › Yii3 Debug › Mail › MailFileStore

final readonly classYii3\Debug\Mail\MailFileStore
Sourcesrc/Mail/MailFileStore.php

Stores the .eml files of captured mail messages and removes them once no retained capture refers to them.

Only bare file names are resolved, so a name read back from a manifest or a request cannot reach outside the mail directory.

MethodDescriptionDefined by
__construct()Creates a mail-file store with its directory, permissions, and optional failure logger.MailFileStore
reconcile()Deletes aged .eml files no retained capture refers to.MailFileStore
remove()Deletes the .eml files of a capture that was evicted from history or never committed.MailFileStore
resolve()Returns the absolute path of a stored .eml file.MailFileStore
write()Writes one message to the mail directory under a new unique name.MailFileStore
public function __construct(string $path, int $dirMode = 0700, int|null $fileMode = 0600, Psr\Log\LoggerInterface|null $logger = null)

Creates a mail-file store with its directory, permissions, and optional failure logger.

Parameters

ParameterTypeDescription
$pathstringDirectory holding the .eml files, already resolved from any alias.
$dirModeintPermission bits applied to the directory when it is created.
$fileModeint|nullPermission bits applied to every written file, or null to keep the process umask.
$loggerPsr\Log\LoggerInterface|nullLogger receiving a warning when a file cannot be written, or null to report the failure only through the empty file name.
public function reconcile(iterable<string> $referencedFiles): void

Deletes aged .eml files no retained capture refers to.

The grace period keeps a file written by a concurrent request whose capture is not committed yet. A file that cannot be deleted stays for the next reconciliation.

Parameters

ParameterTypeDescription
$referencedFilesiterable<string>File names referenced by the committed manifest.
public function remove(iterable<string> $files): void

Deletes the .eml files of a capture that was evicted from history or never committed.

Unsafe or unknown names are skipped. A file that cannot be deleted is left for reconcile().

Parameters

ParameterTypeDescription
$filesiterable<string>File names recorded by the capture.
public function resolve(string $file): string|null

Returns the absolute path of a stored .eml file.

Parameters

ParameterTypeDescription
$filestringFile name as recorded by the capture or requested by the client.

Returns

string|null: Path of the stored file, or null when the name carries a path segment or no such file exists.

public function write(string $content): string

Writes one message to the mail directory under a new unique name.

A failure is logged and leaves no partial file behind, so the capture keeps the message without a stored file.

Parameters

ParameterTypeDescription
$contentstringMessage content, normally the RFC 5322 source of the sent message.

Returns

string: Name of the written file, or '' when it could not be written.