# MailPanel

> Adapts the framework-neutral PHPForge Mail panel to the Yii3 debugger.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Panel](/docs/extensions/yii3-debug/reference/panel/index.md) › MailPanel

| final class | `Yii3\Debug\Panel\MailPanel` |
| --- | --- |
| Extends | [`ProviderPanel`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md) |
| Implements | [`CaptureToolbarProviderInterface`](/docs/extensions/yii3-debug/reference/panel/capturetoolbarproviderinterface/index.md), [`ToolbarPanelProviderInterface`](/docs/extensions/yii3-debug/reference/panel/toolbarpanelproviderinterface/index.md) |
| Source | [`src/Panel/MailPanel.php`](https://github.com/yii3/debug/blob/main/src/Panel/MailPanel.php#L27) |

Adapts the framework-neutral PHPForge Mail panel to the Yii3 debugger.

The detail view, the sidebar entry, and the toolbar metric match the Yii2 Mail panel: a capture that sent mail counts
its own messages, and a capture that sent none but directly follows one that did, the redirect after a form post,
links the metric to that request.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Binds the adapter to the shared Mail presentation. | `MailPanel` |
| [`hasContent()`](#method-hasContent) | Reports whether the Mail collector captured the request. | `MailPanel` |
| <span id="method-icon"></span>[`icon()`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md#method-icon) | Returns the shared Debug Core icon key. | [`ProviderPanel`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md) |
| <span id="method-id"></span>[`id()`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md#method-id) | Returns the stable identifier of this panel. | [`ProviderPanel`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md) |
| <span id="method-name"></span>[`name()`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md#method-name) | Returns the human-readable panel name. | [`ProviderPanel`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md) |
| <span id="method-render"></span>[`render()`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md#method-render) | Renders the detail content the provider produces for a capture. | [`ProviderPanel`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md) |
| [`toolbarItems()`](#method-toolbarItems) | Counts the messages the capture sent. | `MailPanel` |
| [`toolbarItemsForCapture()`](#method-toolbarItemsForCapture) | Counts the messages the capture sent, or links the previous request when it sent the mail instead. | `MailPanel` |
| <span id="method-withMetadata"></span>[`withMetadata()`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md#method-withMetadata) | Returns a copy presenting the panel under the metadata the application configured. | [`ProviderPanel`](/docs/extensions/yii3-debug/reference/panel/providerpanel/index.md) |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(PHPForge\Debug\Storage\SnapshotStore $store, Yii3\Debug\Middleware\ToolbarOptions $options = new \Yii3\Debug\Middleware\ToolbarOptions())
```

Binds the adapter to the shared Mail presentation.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$store` | `PHPForge\Debug\Storage\SnapshotStore` | Store whose manifest locates the request that preceded a capture. |
| `$options` | [`Yii3\Debug\Middleware\ToolbarOptions`](/docs/extensions/yii3-debug/reference/middleware/toolbaroptions/index.md) | Settings carrying the route prefix the cross-request link is built on. |

### hasContent() <span id="method-hasContent"></span>

```php
public function hasContent(array<string, mixed> $payload): bool
```

Reports whether the Mail collector captured the request.

A capture without messages stays listed and shows the panel empty state, as the Yii2 sidebar does.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$payload` | `array<string, mixed>` | Serialized panel payload. |

**Returns**

`bool`: `true` when the collector produced a payload; `false` otherwise.

### toolbarItems() <span id="method-toolbarItems"></span>

```php
public function toolbarItems(array<string, mixed> $payload): list<PHPForge\Debug\Toolbar\ToolbarItem>
```

Counts the messages the capture sent.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$payload` | `array<string, mixed>` | Serialized panel payload. |

**Returns**

`list<PHPForge\Debug\Toolbar\ToolbarItem>`: One metric carrying the message count, or an empty list when none was sent.

**Throws**

- `PHPForge\Debug\Storage\HydrationException`: when the payload does not match the Mail snapshot schema.

### toolbarItemsForCapture() <span id="method-toolbarItemsForCapture"></span>

```php
public function toolbarItemsForCapture(string $tag, array<string, mixed> $payload): list<PHPForge\Debug\Toolbar\ToolbarItem>
```

Counts the messages the capture sent, or links the previous request when it sent the mail instead.

The previous request is the manifest entry right after the capture, newest first; a capture not listed yet falls
back to the newest entry.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$tag` | `string` | Tag of the capture the toolbar describes. |
| `$payload` | `array<string, mixed>` | Serialized panel payload of that capture. |

**Returns**

`list<PHPForge\Debug\Toolbar\ToolbarItem>`: The own count, a `cross-request` metric linking the previous request, or an empty list when neither sent mail.

**Throws**

- `PHPForge\Debug\Storage\HydrationException`: when the payload does not match the Mail snapshot schema.