adachsoft / notification-channel-email
E-mail channel for adachsoft/notification-contracts: resolves recipient addresses and sends plain-text e-mail through a pluggable transport interface (SMTP/provider transports are separate adapters).
Package info
gitlab.com/a.adach/notification-channel-email
pkg:composer/adachsoft/notification-channel-email
Requires
- php: ^8.3
- adachsoft/notification-contracts: ^0.1
- adachsoft/reference-contracts: ^0.1
- psr/clock: ^1.0
Requires (Dev)
- adachsoft/php-code-style: ^0.7.3
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.4
- rector/rector: ^2.8
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
adachsoft/notification-channel-email provides an e-mail channel for adachsoft/notification-contracts. It resolves a leaf recipient's address and sends a plain-text message through an application-provided transport. SMTP clients, provider integrations, and user-store lookups are supplied separately.
Features
- Validated e-mail addresses and message headers.
- Pluggable recipient address resolver and transport interfaces.
- Optional reply-to address and notification category/source headers.
SENTon successful delivery andSKIPPEDwhen no recipient address is available.- In-memory resolver and transport for tests, examples, and simple configurations.
Installation
composer require adachsoft/notification-channel-email
Requirements
- PHP 8.3 or later.
adachsoft/notification-contracts:^0.1.adachsoft/reference-contracts:^0.1.psr/clock:^1.0.
Usage
Provide implementations of EmailAddressResolverInterface and EmailTransportInterface, then construct the channel with those services, a sender address, and a PSR-20 clock:
$channel = new EmailNotificationChannel(
addresses: $addressResolver,
transport: $emailTransport,
from: new EmailAddress('notifications@example.com'),
clock: $clock,
);
$result = $channel->send($notification, $recipient);
The resolver receives a leaf PrincipalReference; expand groups in the dispatcher or an application-level principal resolver. Address-resolution and transport errors are wrapped in NotificationDeliveryException.
See the direct-channel usage example for a complete example using the in-memory adapters. InMemoryEmailTransport records messages and does not send e-mail.