# Mail Log: Extension and action examples

<!-- Maintained by scripts/generate-package-readmes.php -->

Use the action functions with records and Data objects supplied by your application.
They pass each argument to the package operation and return its result.

These adapters show container registration. Use the owning package registry when
a contract requires contributor discovery.

Contract adapters wrap an existing implementation. Call their registration function
from your service provider with that implementation; tagged contracts keep their declared tag.
Resolve the backend by its concrete class before registration so the replacement contract
does not resolve itself. Static contract metadata uses one backend class per adapter.

## Contract `Capell\MailLog\Contracts\RecipientSuppressionList`

<!-- example: contract Capell\MailLog\Contracts\RecipientSuppressionList -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

final class RecipientSuppressionListAdapter implements \Capell\MailLog\Contracts\RecipientSuppressionList
{
    public function __construct(private readonly \Capell\MailLog\Contracts\RecipientSuppressionList $backend) {}

    #[\Override]
    public function isSuppressed(string $address, bool $includeComplaints = true): bool
    {
        return $this->backend->isSuppressed($address, $includeComplaints);
    }
}

function registerRecipientSuppressionListAdapter(\Capell\MailLog\Contracts\RecipientSuppressionList $backend): void
{
    app()->bind(RecipientSuppressionListAdapter::class, static fn (): RecipientSuppressionListAdapter => new RecipientSuppressionListAdapter($backend));
    app()->bind(\Capell\MailLog\Contracts\RecipientSuppressionList::class, RecipientSuppressionListAdapter::class);
    app()->tag([RecipientSuppressionListAdapter::class], \Capell\MailLog\Contracts\RecipientSuppressionList::TAG);
}
```

## Action `alertAdminsOfHeldOutboundMessages`

<!-- example: action alertAdminsOfHeldOutboundMessages -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runAlertAdminsOfHeldOutboundMessages(\Capell\MailLog\Models\OutboundMessageBreaker $breaker, \Capell\Core\Data\Messaging\OutboundMessageSourceData $source): int
{
    return \Capell\MailLog\Actions\AlertAdminsOfHeldOutboundMessagesAction::run($breaker, $source);
}
```

## Action `applyMailProviderEvent`

<!-- example: action applyMailProviderEvent -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runApplyMailProviderEvent(\Capell\MailLog\Data\MailProviderEventData $event): ?\Capell\MailLog\Models\MailLogEntry
{
    return \Capell\MailLog\Actions\ApplyMailProviderEventAction::run($event);
}
```

## Action `applyPostmarkMailEvent`

<!-- example: action applyPostmarkMailEvent -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runApplyPostmarkMailEvent(\Capell\MailLog\Data\PostmarkMailEventData $event): ?\Capell\MailLog\Models\MailLogEntry
{
    return \Capell\MailLog\Actions\ApplyPostmarkMailEventAction::run($event);
}
```

## Action `buildMailHealthDigest`

<!-- example: action buildMailHealthDigest -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runBuildMailHealthDigest(\Carbon\CarbonImmutable $date, int $limit = 5): \Capell\MailLog\Data\MailHealthDigestData
{
    return \Capell\MailLog\Actions\BuildMailHealthDigestAction::run($date, $limit);
}
```

## Action `buildMailLogPrivacyExport`

<!-- example: action buildMailLogPrivacyExport -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runBuildMailLogPrivacyExport(\Capell\Core\Data\Privacy\PrivacySubject $subject): array
{
    return \Capell\MailLog\Actions\BuildMailLogPrivacyExportAction::run($subject);
}
```

## Action `buildOutboundMessageHealth`

<!-- example: action buildOutboundMessageHealth -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runBuildOutboundMessageHealth(\Carbon\CarbonImmutable $from, \Carbon\CarbonImmutable $to): array
{
    return \Capell\MailLog\Actions\BuildOutboundMessageHealthAction::run($from, $to);
}
```

## Action `captureOutboundMessage`

<!-- example: action captureOutboundMessage -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runCaptureOutboundMessage(\Capell\Core\Data\Messaging\OutboundMessageSourceData $source, ?\Closure $payload = null): bool
{
    return \Capell\MailLog\Actions\CaptureOutboundMessageAction::run($source, $payload);
}
```

## Action `discardHeldOutboundMessages`

<!-- example: action discardHeldOutboundMessages -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runDiscardHeldOutboundMessages(iterable $ids, ?\Illuminate\Contracts\Auth\Authenticatable $user = null, bool $includeSending = false): int
{
    return \Capell\MailLog\Actions\DiscardHeldOutboundMessagesAction::run($ids, $user, $includeSending);
}
```

## Action `eraseMailLogPrivacyData`

<!-- example: action eraseMailLogPrivacyData -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runEraseMailLogPrivacyData(\Capell\Core\Data\Privacy\PrivacySubject $subject): int
{
    return \Capell\MailLog\Actions\EraseMailLogPrivacyDataAction::run($subject);
}
```

## Action `evaluateOutboundMessageHealth`

<!-- example: action evaluateOutboundMessageHealth -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runEvaluateOutboundMessageHealth(?\Carbon\CarbonImmutable $now = null): array
{
    return \Capell\MailLog\Actions\EvaluateOutboundMessageHealthAction::run($now);
}
```

## Action `markMailSent`

<!-- example: action markMailSent -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runMarkMailSent(\Illuminate\Mail\SentMessage $sent, ?string $mailer = null): ?\Capell\MailLog\Models\MailLogEntry
{
    return \Capell\MailLog\Actions\MarkMailSentAction::run($sent, $mailer);
}
```

## Action `markOutboundMessageSourceReviewed`

<!-- example: action markOutboundMessageSourceReviewed -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runMarkOutboundMessageSourceReviewed(\Capell\MailLog\Models\OutboundMessageSource $source, ?\Illuminate\Contracts\Auth\Authenticatable $reviewer = null): \Capell\MailLog\Models\OutboundMessageSource
{
    return \Capell\MailLog\Actions\MarkOutboundMessageSourceReviewedAction::run($source, $reviewer);
}
```

## Action `markUnconfirmedMailFailed`

<!-- example: action markUnconfirmedMailFailed -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runMarkUnconfirmedMailFailed(?\Throwable $throwable = null): int
{
    return \Capell\MailLog\Actions\MarkUnconfirmedMailFailedAction::run($throwable);
}
```

## Action `notifyAdminsOfNewOutboundMessage`

<!-- example: action notifyAdminsOfNewOutboundMessage -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runNotifyAdminsOfNewOutboundMessage(\Capell\MailLog\Models\OutboundMessageSource $source): int
{
    return \Capell\MailLog\Actions\NotifyAdminsOfNewOutboundMessageAction::run($source);
}
```

## Action `notifyAdminsOfSourceHealth`

<!-- example: action notifyAdminsOfSourceHealth -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runNotifyAdminsOfSourceHealth(\Capell\MailLog\Models\OutboundMessageSource $source, array $incidents, bool $recovered): int
{
    return \Capell\MailLog\Actions\NotifyAdminsOfSourceHealthAction::run($source, $incidents, $recovered);
}
```

## Action `purgeMailLog`

<!-- example: action purgeMailLog -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runPurgeMailLog(): \Capell\MailLog\Data\MailLogPurgeResultData
{
    return \Capell\MailLog\Actions\PurgeMailLogAction::run();
}
```

## Action `recordOutgoingMail`

<!-- example: action recordOutgoingMail -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runRecordOutgoingMail(\Symfony\Component\Mime\Email $message, array $data, ?\Capell\Core\Data\Messaging\OutboundMessageSourceData $source = null): ?\Capell\MailLog\Models\MailLogEntry
{
    return \Capell\MailLog\Actions\RecordOutgoingMailAction::run($message, $data, $source);
}
```

## Action `releaseHeldOutboundMessages`

<!-- example: action releaseHeldOutboundMessages -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runReleaseHeldOutboundMessages(iterable $ids, ?\Illuminate\Contracts\Auth\Authenticatable $user = null): int
{
    return \Capell\MailLog\Actions\ReleaseHeldOutboundMessagesAction::run($ids, $user);
}
```

## Action `renderMailHealthDigestSection`

<!-- example: action renderMailHealthDigestSection -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runRenderMailHealthDigestSection(\Carbon\CarbonImmutable $date, int $limit = 5): string
{
    return \Capell\MailLog\Actions\RenderMailHealthDigestSectionAction::run($date, $limit);
}
```

## Action `resolveMailLogSettings`

<!-- example: action resolveMailLogSettings -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runResolveMailLogSettings(): \Capell\MailLog\Data\MailLogSettingsData
{
    return \Capell\MailLog\Actions\ResolveMailLogSettingsAction::run();
}
```

## Action `resolveMailLogSubjectHashes`

<!-- example: action resolveMailLogSubjectHashes -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runResolveMailLogSubjectHashes(\Capell\Core\Data\Privacy\PrivacySubject $subject): array
{
    return \Capell\MailLog\Actions\ResolveMailLogSubjectHashesAction::run($subject);
}
```

## Action `resolveOutboundMessageSource`

<!-- example: action resolveOutboundMessageSource -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runResolveOutboundMessageSource(array $mailData): \Capell\Core\Data\Messaging\OutboundMessageSourceData
{
    return \Capell\MailLog\Actions\ResolveOutboundMessageSourceAction::run($mailData);
}
```

## Action `setOutboundMessageBreaker`

<!-- example: action setOutboundMessageBreaker -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runSetOutboundMessageBreaker(string $scope, bool $tripped, ?\Illuminate\Contracts\Auth\Authenticatable $user = null): void
{
    \Capell\MailLog\Actions\SetOutboundMessageBreakerAction::run($scope, $tripped, $user);
}
```

## Action `setOutboundMessageSourceEngagement`

<!-- example: action setOutboundMessageSourceEngagement -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runSetOutboundMessageSourceEngagement(\Capell\MailLog\Models\OutboundMessageSource $source, bool $enabled): \Capell\MailLog\Models\OutboundMessageSource
{
    return \Capell\MailLog\Actions\SetOutboundMessageSourceEngagementAction::run($source, $enabled);
}
```

## Action `setOutboundMessageSourceHealthThresholds`

<!-- example: action setOutboundMessageSourceHealthThresholds -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runSetOutboundMessageSourceHealthThresholds(\Capell\MailLog\Models\OutboundMessageSource $source, array $limits): \Capell\MailLog\Models\OutboundMessageSource
{
    return \Capell\MailLog\Actions\SetOutboundMessageSourceHealthThresholdsAction::run($source, $limits);
}
```

## Action `suppressMailRecipients`

<!-- example: action suppressMailRecipients -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runSuppressMailRecipients(\Capell\MailLog\Models\MailLogEntry $entry, \Capell\MailLog\Data\MailProviderEventData $event, \Capell\MailLog\Enums\MailSuppressionReason $reason): int
{
    return \Capell\MailLog\Actions\SuppressMailRecipientsAction::run($entry, $event, $reason);
}
```

## Action `syncOutboundMessageCatalogue`

<!-- example: action syncOutboundMessageCatalogue -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runSyncOutboundMessageCatalogue(): int
{
    return \Capell\MailLog\Actions\SyncOutboundMessageCatalogueAction::run();
}
```

## Action `updateOutboundMessageBaselines`

<!-- example: action updateOutboundMessageBaselines -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\MailLog;

function runUpdateOutboundMessageBaselines(?\Carbon\CarbonImmutable $at = null): int
{
    return \Capell\MailLog\Actions\UpdateOutboundMessageBaselinesAction::run($at);
}
```