# boolean_smtp_email_failed

> Fires after a send attempt has failed, before the fallback connection is tried.

Action · Tier A · Since 1.0.0

Fires for every failed attempt, so it can fire and the message still be delivered by the fallback connection; build failure alerts on `boolean_smtp_email_delivery_failed_final` instead. The payload has passed through `boolean_smtp_email_event_data`.

## Signature

```php
add_action( 'boolean_smtp_email_failed', $callback, 10, 1 );
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `$payload` | `array<string, mixed>` |  |
| &nbsp;&nbsp;`to` | `string` | Recipient address(es), comma separated. |
| &nbsp;&nbsp;`subject` | `string` | Subject line. |
| &nbsp;&nbsp;`error` | `string` | Error message. |
| &nbsp;&nbsp;`code` | `int` | Numeric error code, `0` when the error carried none. |
| &nbsp;&nbsp;`log_id` | `int` | Id of the email log entry. |
| &nbsp;&nbsp;`connection_id` | `int|null` | Id of the connection used, `null` when unknown. |
| &nbsp;&nbsp;`provider` | `string` | Provider of the connection used. |

## Fires in

- [app/Services/Mailer/EmailLogSendLifecycle.php:251](https://github.com/booleanpress/boolean-smtp-src/blob/main/app/Services/Mailer/EmailLogSendLifecycle.php#L251) — `BooleanSmtp\Services\Mailer\EmailLogSendLifecycle::onWpMailFailed()`

## Example

```php
add_action( 'boolean_smtp_email_failed', function ( array $payload ) {
    // React to the event.
}, 10, 1 );
```
