# boolean_smtp_should_log_email

> Filters whether a message is written to the email log.

Filter · Tier A · Since 1.0.0

Runs after the global logging setting has allowed the message, immediately before its log entry would be created. Return `false` to keep this message out of the log — a newsletter, a message with personal data, a high-volume transactional stream, or (as the add-on's plugin exclusions do) everything a given plugin sends. Not consulted for a queued message, a resend or a fallback retry: their log entry already exists and records the attempt.

## Signature

```php
add_filter( 'boolean_smtp_should_log_email', $callback, 10, 3 );
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `$log` | `bool` | Whether to log the message. Default `true`. |
| `$mail_data` | `array<string, mixed>` | The message: `to`, `cc`, `bcc`, `from_email`, `from_name`, `subject`, `headers` (name => value) and `source` (the plugin or theme that sent it, when known). |
| `$connection` | `\BooleanSmtp\Models\Connection|null` | The connection the message is sent through, `null` when it is not known yet. |

**Returns** `bool` — Whether to log the message.

## Fires in

- [app/Services/Mailer/MailerManager.php:1603](https://github.com/booleanpress/boolean-smtp-src/blob/main/app/Services/Mailer/MailerManager.php#L1603) — `BooleanSmtp\Services\Mailer\MailerManager::shouldLogEmail()`

## Example

```php
add_filter( 'boolean_smtp_should_log_email', function ( bool $log, array $mail_data, ?\BooleanSmtp\Models\Connection $connection ) {
    return $log;
}, 10, 3 );
```
