# MailEntry

> Typed view-model for a single mail message rendered in the Mail panel detail view.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Mail](/docs/extensions/debug-core/reference/panel/mail/index.md) › MailEntry

| final class | `PHPForge\Debug\Panel\Mail\MailEntry` |
| --- | --- |
| Implements | [`PHPForge\Debug\Storage\PanelRow`](/docs/extensions/debug-core/reference/storage/panelrow/index.md) |
| Source | [`src/Panel/Mail/MailEntry.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Mail/MailEntry.php#L22) |

Typed view-model for a single mail message rendered in the Mail panel detail view.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`create()`](#method-create) static | Creates a captured message from the envelope fields every mailer reports. | `MailEntry` |
| [`failedCount()`](#method-failedCount) static | Counts the messages the mailer rejected. | `MailEntry` |
| [`fromArray()`](#method-fromArray) static | Narrows one persisted message of the mail payload into a typed entry. | `MailEntry` |
| [`fromCapture()`](#method-fromCapture) static | Narrows one captured `EVENT_AFTER_SEND` payload into a typed message. | `MailEntry` |
| [`getBcc()`](#method-getBcc) | Returns the blind carbon-copy recipients. | `MailEntry` |
| [`getBody()`](#method-getBody) | Returns the captured plain-text body. | `MailEntry` |
| [`getCc()`](#method-getCc) | Returns the carbon-copy recipients. | `MailEntry` |
| [`getCharset()`](#method-getCharset) | Returns the charset declared on the message. | `MailEntry` |
| [`getFile()`](#method-getFile) | Returns the path of the message the mailer persisted. | `MailEntry` |
| [`getFrom()`](#method-getFrom) | Returns the sender address as captured. | `MailEntry` |
| [`getHeaders()`](#method-getHeaders) | Returns the raw message headers as captured. | `MailEntry` |
| [`getReplyTo()`](#method-getReplyTo) | Returns the reply-to addresses. | `MailEntry` |
| [`getSubject()`](#method-getSubject) | Returns the subject line as captured. | `MailEntry` |
| [`getTime()`](#method-getTime) | Returns the capture timestamp. | `MailEntry` |
| [`getTo()`](#method-getTo) | Returns the primary recipients. | `MailEntry` |
| [`isSuccessful()`](#method-isSuccessful) | Reports whether the mailer delivered the message. | `MailEntry` |
| [`jsonSerialize()`](#method-jsonSerialize) | Serializes the message into its persisted payload. | `MailEntry` |
| [`withBcc()`](#method-withBcc) | Returns a copy with the blind carbon-copy recipients. | `MailEntry` |
| [`withBody()`](#method-withBody) | Returns a copy with the captured body. | `MailEntry` |
| [`withCc()`](#method-withCc) | Returns a copy with the carbon-copy recipients. | `MailEntry` |
| [`withCharset()`](#method-withCharset) | Returns a copy with the declared charset. | `MailEntry` |
| [`withFile()`](#method-withFile) | Returns a copy with the persisted message file. | `MailEntry` |
| [`withHeaders()`](#method-withHeaders) | Returns a copy with the raw message headers. | `MailEntry` |
| [`withReplyTo()`](#method-withReplyTo) | Returns a copy with the reply-to addresses. | `MailEntry` |
| [`withTime()`](#method-withTime) | Returns a copy with the capture timestamp. | `MailEntry` |

## Method details

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

```php
public static function create(string $from, list<string> $to, string $subject, bool $isSuccessful): self
```

Creates a captured message from the envelope fields every mailer reports.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$from` | `string` | Sender address as captured. |
| `$to` | `list<string>` | Primary recipients, with empty entries dropped. |
| `$subject` | `string` | Subject line as captured. |
| `$isSuccessful` | `bool` | Whether the mailer reported the message as sent. |

**Returns**

`self`: Message carrying the envelope, without body, headers, or capture time.

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

```php
public static function failedCount(list<self> $models): int
```

Counts the messages the mailer rejected.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$models` | `list<self>` | Captured messages. |

**Returns**

`int`: Number of messages reported as failed.

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

```php
public static function fromArray(mixed $data, string $path): self
```

Narrows one persisted message of the mail payload into a typed entry.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Persisted message, expected to be an object carrying the declared shape. |
| `$path` | `string` | JSON path of the message, used to report a malformed payload. |

**Returns**

`self`: Message carrying every persisted field.

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

```php
public static function fromCapture(array<array-key, mixed> $row): self
```

Narrows one captured `EVENT_AFTER_SEND` payload into a typed message.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$row` | `array<array-key, mixed>` | Captured payload. |

**Returns**

`self`: Message carrying every field the mailer exposed.

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

```php
public function getBcc(): list<string>
```

Returns the blind carbon-copy recipients.

**Returns**

`list<string>`: Blind carbon-copy recipients in capture order.

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

```php
public function getBody(): string
```

Returns the captured plain-text body.

**Returns**

`string`: Plain-text body, or `''` when the message had none.

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

```php
public function getCc(): list<string>
```

Returns the carbon-copy recipients.

**Returns**

`list<string>`: Carbon-copy recipients in capture order.

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

```php
public function getCharset(): string
```

Returns the charset declared on the message.

**Returns**

`string`: Declared charset, or `''` when none was set.

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

```php
public function getFile(): string
```

Returns the path of the message the mailer persisted.

**Returns**

`string`: Path to the persisted `.eml` file, or `''` when the mailer exposes none.

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

```php
public function getFrom(): string
```

Returns the sender address as captured.

**Returns**

`string`: Sender address as captured.

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

```php
public function getHeaders(): string
```

Returns the raw message headers as captured.

**Returns**

`string`: Raw RFC-5322 headers, joined with line breaks.

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

```php
public function getReplyTo(): list<string>
```

Returns the reply-to addresses.

**Returns**

`list<string>`: Reply-to addresses in capture order.

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

```php
public function getSubject(): string
```

Returns the subject line as captured.

**Returns**

`string`: Subject line as captured.

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

```php
public function getTime(): int|null
```

Returns the capture timestamp.

**Returns**

`int|null`: Capture timestamp as a Unix-epoch second, or `null` when the payload carried no parseable time.

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

```php
public function getTo(): list<string>
```

Returns the primary recipients.

**Returns**

`list<string>`: Primary recipients in capture order.

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

```php
public function isSuccessful(): bool
```

Reports whether the mailer delivered the message.

**Returns**

`bool`: `true` when the mailer reported the message as sent.

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

```php
public function jsonSerialize(): array<string, mixed>
```

Serializes the message into its persisted payload.

**Returns**

`array<string, mixed>`

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

```php
public function withBcc(list<string> $bcc): self
```

Returns a copy with the blind carbon-copy recipients.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$bcc` | `list<string>` | Recipients in capture order. |

**Returns**

`self`: New instance carrying the requested recipients.

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

```php
public function withBody(string $body): self
```

Returns a copy with the captured body.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$body` | `string` | Plain-text body, or `''` when the message had none. |

**Returns**

`self`: New instance carrying the requested body.

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

```php
public function withCc(list<string> $cc): self
```

Returns a copy with the carbon-copy recipients.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$cc` | `list<string>` | Recipients in capture order. |

**Returns**

`self`: New instance carrying the requested recipients.

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

```php
public function withCharset(string $charset): self
```

Returns a copy with the declared charset.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$charset` | `string` | Charset declared on the message, or `''` when none was set. |

**Returns**

`self`: New instance carrying the requested charset.

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

```php
public function withFile(string $file): self
```

Returns a copy with the persisted message file.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$file` | `string` | Path to the `.eml` file, or `''` when the mailer exposes none. |

**Returns**

`self`: New instance carrying the requested file.

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

```php
public function withHeaders(string $headers): self
```

Returns a copy with the raw message headers.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$headers` | `string` | Raw RFC-5322 headers, joined with line breaks. |

**Returns**

`self`: New instance carrying the requested headers.

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

```php
public function withReplyTo(list<string> $replyTo): self
```

Returns a copy with the reply-to addresses.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$replyTo` | `list<string>` | Addresses in capture order. |

**Returns**

`self`: New instance carrying the requested addresses.

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

```php
public function withTime(int|null $time): self
```

Returns a copy with the capture timestamp.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$time` | `int\|null` | Unix-epoch second, or `null` when the payload carried no parseable time. |

**Returns**

`self`: New instance carrying the requested timestamp.